On Mon, Aug 02, 2021 at 11:36:47PM +0200, Jesper Wallin wrote: > On Mon, Aug 02, 2021 at 08:28:00PM +0200, Florian Obser wrote: > > On 2021-07-28 23:02 +02, Jesper Wallin <jes...@ifconfig.se> wrote: > > > Hi tech@ > > > > > > I've setup my machine to use trunk(4) with re(4) and iwm(4) as failover, > > > to make life easier when switching between wired and wireless > > > networking. The wired network at home is on a different subnet from > > > the wireless network, so when I unplug the cable, a DHCP request is > > > > I don't think this is a correct configuration (I accidentally made this > > work in 2019, sorry about that). > > Can't you use > > inet autoconf > > in hostname.re0 *and* hostname.iwm0? > > Oh? I've used this configuration for little over 3 years now and I > thought the IP/configuration should be trunk0 based on the examples in > trunk(4) and https://www.openbsd.org/faq/faq6.html#Wireless. > > I *could* do it the way you suggest, of course, but I thought this was a > bug/regression, as it worked fine with dhclient(8). In my network > configuration, of separating the wired and wireless network, it wouldn't > be an issue. On networks where the wired and wireless network are on > the same subnet though, it would be a shame to lose the ability to have > it seemlessly jump from one to another without losing any connections.
Err, scratch that last paragraph. If they're on the same network, why would a DHCPREQUEST be needed?! Note to self, think before posting. Too much Monday today. > > > required to get my connection to work again. Before, dhcpleased(8), > > > dhclient(8) handled this as expected. > > > > > > I skimmed through the code to try to understand how dhclient(8) handles > > > this, but I'm not sure I fully understand this. My first take was to > > > change the rtfilter, as I noticed dhclient(8) was listening for way more > > > things. But after some testing I learned that RTM_IFINFO was enough, > > > even if trunk(4) remains "active" and UP when the cable is unplugged. > > > > > > This solution might not be optimal, as I've basically just removed some > > > of the checks in engine_update_iface() that return early if nothing has > > > changed on the interface. At least it solves my issue with trunk(4) and > > > so far I haven't managed to spawn any dragons from this. Though, this > > > might cause engine_update_iface() to fully more often? > > > > > > Thoughts? > > > > > > Index: engine.c > > > =================================================================== > > > RCS file: /cvs/src/sbin/dhcpleased/engine.c,v > > > retrieving revision 1.22 > > > diff -u -p -r1.22 engine.c > > > --- engine.c 26 Jul 2021 09:26:36 -0000 1.22 > > > +++ engine.c 28 Jul 2021 20:39:45 -0000 > > > @@ -586,7 +586,6 @@ void > > > engine_update_iface(struct imsg_ifinfo *imsg_ifinfo) > > > { > > > struct dhcpleased_iface *iface; > > > - int need_refresh = 0; > > > > > > iface = get_dhcpleased_iface_by_id(imsg_ifinfo->if_index); > > > > > > @@ -604,32 +603,14 @@ engine_update_iface(struct imsg_ifinfo * > > > memcpy(&iface->hw_address, &imsg_ifinfo->hw_address, > > > sizeof(struct ether_addr)); > > > LIST_INSERT_HEAD(&dhcpleased_interfaces, iface, entries); > > > - need_refresh = 1; > > > } else { > > > - if (memcmp(&iface->hw_address, &imsg_ifinfo->hw_address, > > > - sizeof(struct ether_addr)) != 0) { > > > - memcpy(&iface->hw_address, &imsg_ifinfo->hw_address, > > > - sizeof(struct ether_addr)); > > > - need_refresh = 1; > > > - } > > > - if (imsg_ifinfo->rdomain != iface->rdomain) { > > > - iface->rdomain = imsg_ifinfo->rdomain; > > > - need_refresh = 1; > > > - } > > > - if (imsg_ifinfo->running != iface->running) { > > > - iface->running = imsg_ifinfo->running; > > > - need_refresh = 1; > > > - } > > > - > > > - if (imsg_ifinfo->link_state != iface->link_state) { > > > - iface->link_state = imsg_ifinfo->link_state; > > > - need_refresh = 1; > > > - } > > > + memcpy(&iface->hw_address, &imsg_ifinfo->hw_address, > > > + sizeof(struct ether_addr)); > > > + iface->rdomain = imsg_ifinfo->rdomain; > > > + iface->running = imsg_ifinfo->running; > > > + iface->link_state = imsg_ifinfo->link_state; > > > } > > > > > > - if (!need_refresh) > > > - return; > > > - > > > if (iface->running && LINK_STATE_IS_UP(iface->link_state)) { > > > if (iface->requested_ip.s_addr == INADDR_ANY) > > > parse_lease(iface, imsg_ifinfo); > > > @@ -641,6 +622,7 @@ engine_update_iface(struct imsg_ifinfo * > > > } else > > > state_transition(iface, IF_DOWN); > > > } > > > + > > > struct dhcpleased_iface* > > > get_dhcpleased_iface_by_id(uint32_t if_index) > > > { > > > Index: frontend.c > > > =================================================================== > > > RCS file: /cvs/src/sbin/dhcpleased/frontend.c,v > > > retrieving revision 1.15 > > > diff -u -p -r1.15 frontend.c > > > --- frontend.c 27 Jul 2021 18:17:37 -0000 1.15 > > > +++ frontend.c 28 Jul 2021 20:39:45 -0000 > > > @@ -605,11 +605,9 @@ update_iface(struct if_msghdr *ifm, stru > > > } > > > } > > > > > > - if (memcmp(&iface->ifinfo, &ifinfo, sizeof(iface->ifinfo)) != 0) { > > > - memcpy(&iface->ifinfo, &ifinfo, sizeof(iface->ifinfo)); > > > - frontend_imsg_compose_main(IMSG_UPDATE_IF, 0, &iface->ifinfo, > > > - sizeof(iface->ifinfo)); > > > - } > > > + memcpy(&iface->ifinfo, &ifinfo, sizeof(iface->ifinfo)); > > > + frontend_imsg_compose_main(IMSG_UPDATE_IF, 0, &iface->ifinfo, > > > + sizeof(iface->ifinfo)); > > > } > > > > > > void > > > > > > > -- > > I'm not entirely sure you are real. > > >