Access host device which bridges a connected device through same eth interface
I got 2 small computers running Linux. One acts as ethernet gadget, connected via USB to the other, the host.
I set up a bridge, like so:
ip link add name br0 type bridge ip link set dev br0 up ip link set dev eth0 master br0 ip link set dev usb0 master br0
On the gadget, its usb0 interface has 2 IP addresses: the one in the 169.... net that the host also has on its usb0, which I consider the "internal" connection/subnet between the two computers - and the second IP on the gadget is one in the "outside" subnet, which the bridging host is connected to with its eth0 interface.
This almost works. Except, when I run the script that sets up the bridge, I cannot connect to the host anymore, e.g. SSH into it with its eth0's own IP address.
Edit: What's weird is that establishing SSH connections to the host eth0's own IP still works for a while (e.g. a few minutes) after setting up the bridge, but ceases to work then.
I found something here, indicating that, if eth0 has a bridge to something else, it's not supposed to have an own IP address. The text suggests to add an address to the bridge:
ip addr flush dev eth0 ip addr add 192.168.128.5/24 dev br0 ip link set br0 up
That didn't help, though.
The goal is to be able to access both from the outside world (a local network with a bunch more computers), with all thinkable protocols: the host device, as well as the gadget, and bridging seemed like the way.
How is this done correctly?