On Tue, Nov 29, 2016 at 12:14:40PM +0100, Jeremie Courreges-Anglas wrote: > Remi Locherer <remi.loche...@relo.ch> writes: > > > On Sat, Nov 26, 2016 at 09:39:40AM +0100, Jeremie Courreges-Anglas wrote: > >> Remi Locherer <remi.loche...@relo.ch> writes: > >> > >> > Hi, > >> > > >> > I ran into problems with mtu sizes on interfaces (gif in my case) and > >> > ospfd. mtu was not the same on both sites so adjacency could not be > >> > formed. The mtu mismatch is also logged by ospfd. > >> > > >> > Just changing the MTU with ifconfig is not enough in such a case. I did > >> > not want to restart ospfd since that produces an outage. What I did: > >> > > >> > * ifconfig gif1 down > >> > * vi /etc/ospfd.conf -> remove gif1 > >> > * ospfctl reload > >> > * ifconfig gif1 mtu 1380 up > >> > * vi /etc/ospfd.conf -> add gif1 > >> > * ospfctl reload > >> > > >> > To make this a bit easier I propose the below two patches. > >> > > >> > The first displays the mtu currently known by ospd with ospfctl. Eg: > >> > > >> > ----- > >> > remi@mistral:~% doas /usr/src/usr.sbin/ospfctl/obj/ospfctl sho int iwm0 > >> > > >> > Interface iwm0, line protocol is UP > >> > Internet address 172.18.35.224/24, Area 0.0.0.0 > >> > Linkstate active, MTU 1500 > >> > ^^^^^^^^ > >> > Router ID 10.10.10.1, network type BROADCAST, cost: 10 > >> > Transmit delay is 1 sec(s), state DR, priority 1 > >> > Designated Router (ID) 10.10.10.1, interface address 172.18.35.224 > >> > Backup Designated Router (ID) 0.0.0.0, interface address 0.0.0.0 > >> > Timer intervals configured, hello 10, dead 40, wait 40, retransmit 5 > >> > Hello timer due in 00:00:06+345msec > >> > Uptime 00:00:44 > >> > Neighbor count is 0, adjacent neighbor count is 0 > >> > ----- > >> > >> Makes sense. > >> > >> > > >> > The second patch allows ospfd to learn about a changed mtu value (or > >> > other > >> > interface configs) with a "ospfctl reload". > >> > > >> > Would it be better if an mtu change generates a route message that is > >> > picked up by ospfd the same way as other changes to interfaces configs? > >> > >> I think so. Does the diff below work for you? > >> > > > > Yes this works. With that I can just fix the mtu without reloading ospfd. > > Nice! > > Thanks for confirming. There's one thing that bugs me when I change the > mtu on an interface: > > if_fsm: interface vether0, event UP not expected in state WAIT > interface vether0 up > if_fsm: interface vether0, event UP not expected in state WAIT > interface vether0 up > > "not expected" or "really, should not happen"? Maybe this routing > message (or the one that could be sent for SIOCSIFXFLAGS) is breaking > some kind of assumption here? Input welcome.
Sorry to not reply any sooner. The message is generated by if_fsm in interface.c. I found Claudio's drawing from the interface state machine here: https://www.openbsd.org/papers/eurobsd2005/claudio/mgp00015.html If the mtu is changed while OSPF is running state machine has no definition for handling the event IF_EVT_UP. This additional patch teachs ospfd that no action is required in this situation. The message is now: if_fsm: event UP resulted in action NOTHING and changing state for interface pair0 from DR to DR interface pair0 up I checked what a Brocade FastIron router does when the mtu (ip mtu) changes after the ospf adjacency has been formed: nothing. Index: interface.c =================================================================== RCS file: /cvs/src/usr.sbin/ospfd/interface.c,v retrieving revision 1.81 diff -u -p -r1.81 interface.c --- interface.c 5 Dec 2015 12:20:13 -0000 1.81 +++ interface.c 5 Dec 2016 17:02:40 -0000 @@ -55,6 +55,8 @@ struct { } iface_fsm[] = { /* current state event that happened action to take resulting state */ {IF_STA_DOWN, IF_EVT_UP, IF_ACT_STRT, 0}, + {IF_STA_WAITING, IF_EVT_UP, IF_ACT_NOTHING, 0}, + {IF_STA_MULTI, IF_EVT_UP, IF_ACT_NOTHING, 0}, {IF_STA_WAITING, IF_EVT_BACKUP_SEEN, IF_ACT_ELECT, 0}, {IF_STA_WAITING, IF_EVT_WTIMER, IF_ACT_ELECT, 0}, {IF_STA_ANY, IF_EVT_WTIMER, IF_ACT_NOTHING, 0}, > > > >> Index: sys/net/if.c > >> =================================================================== > >> RCS file: /d/cvs/src/sys/net/if.c,v > >> retrieving revision 1.462 > >> diff -u -p -r1.462 if.c > >> --- sys/net/if.c 21 Nov 2016 09:09:06 -0000 1.462 > >> +++ sys/net/if.c 26 Nov 2016 08:26:08 -0000 > >> @@ -1886,6 +1886,8 @@ ifioctl(struct socket *so, u_long cmd, c > >> if (ifp->if_ioctl == NULL) > >> return (EOPNOTSUPP); > >> error = (*ifp->if_ioctl)(ifp, cmd, data); > >> + if (!error) > >> + rt_ifmsg(ifp); > >> break; > >> > >> case SIOCSIFPHYADDR: > >> Index: usr.sbin/ospfctl/ospfctl.c > >> =================================================================== > >> RCS file: /d/cvs/src/usr.sbin/ospfctl/ospfctl.c,v > >> retrieving revision 1.63 > >> diff -u -p -r1.63 ospfctl.c > >> --- usr.sbin/ospfctl/ospfctl.c 3 Dec 2015 11:42:14 -0000 1.63 > >> +++ usr.sbin/ospfctl/ospfctl.c 26 Nov 2016 08:23:52 -0000 > >> @@ -434,8 +434,9 @@ show_interface_detail_msg(struct imsg *i > >> inet_ntoa(iface->addr), > >> mask2prefixlen(iface->mask.s_addr)); > >> printf("Area %s\n", inet_ntoa(iface->area)); > >> - printf(" Linkstate %s\n", > >> + printf(" Linkstate %s,", > >> get_linkstate(iface->if_type, iface->linkstate)); > >> + printf(" MTU %d\n", iface->mtu); > >> printf(" Router ID %s, network type %s, cost: %d\n", > >> inet_ntoa(iface->rtr_id), > >> if_type_name(iface->type), iface->metric); > >> Index: usr.sbin/ospfd/ospfe.c > >> =================================================================== > >> RCS file: /d/cvs/src/usr.sbin/ospfd/ospfe.c,v > >> retrieving revision 1.96 > >> diff -u -p -r1.96 ospfe.c > >> --- usr.sbin/ospfd/ospfe.c 3 Sep 2016 10:22:57 -0000 1.96 > >> +++ usr.sbin/ospfd/ospfe.c 26 Nov 2016 08:30:34 -0000 > >> @@ -318,6 +318,7 @@ ospfe_dispatch_main(int fd, short event, > >> iface->flags = kif->flags; > >> iface->linkstate = > >> kif->link_state; > >> + iface->mtu = kif->mtu; > >> > >> if (link_ok) { > >> if_fsm(iface, > >> > >> > >> -- > >> jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE > > > > -- > jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE