On 28/05/15(Thu) 11:40, Johan Ymerson wrote:
> Hi,
>
> After the fix in carp to correctly initialize link state (ip_carp.c
> r1.257), ospfd no longer detect all carp interfaces in "backup" mode
> reliably on start-up. The problem is that carp interfaces in backup
> state isn't handled the same way on start-up as it is when up and
> running.
>
> Here is an example incorrectly detected carp interfaces:
> Interface Address State HelloTimer Linkstate Uptime nc ac
> carp7 195.58.98.145/28 DOWN - backup 00:00:00 0 0
> carp5 192.168.253.1/24 DOWN - backup 00:00:00 0 0
> carp3 192.168.202.1/24 DOWN - backup 00:00:00 0 0
> carp2 192.168.254.1/23 DOWN - backup 00:00:00 0 0
> carp1 31.15.61.129/26 DOWN - invalid 00:00:00 0 0
> carp0 92.33.0.202/30 DOWN - invalid 00:00:00 0 0
> bnx0 192.168.200.5/24 OTHER 00:00:02 active 00:01:47 4 2
>
> After restarting ospfd, it detects the correct link state:
> Interface Address State HelloTimer Linkstate Uptime nc ac
> carp7 195.58.98.145/28 DOWN - backup 00:00:00 0 0
> carp5 192.168.253.1/24 DOWN - backup 00:00:00 0 0
> carp3 192.168.202.1/24 DOWN - backup 00:00:00 0 0
> carp2 192.168.254.1/23 DOWN - backup 00:00:00 0 0
> carp1 31.15.61.129/26 DOWN - backup 00:00:00 0 0
> carp0 92.33.0.202/30 DOWN - backup 00:00:00 0 0
> bnx0 192.168.200.5/24 OTHER 00:00:00 active 00:01:29 4 2
>
> The current start-up code ignores the link state transition from INVALID
> to DOWN, as both are regarded as down. If this transition happens during
> ospfd start-up, ospfd will regard the interface as "invalid". Otherwise
> it will correctly be regarded as "backup".
>
>
> Here is a patch that fixes that by having the same exception for carp
> interfaces during startup:
Committed! Thanks and sorry for the delay.
> Index: usr.sbin/ospfd/interface.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/ospfd/interface.c,v
> retrieving revision 1.75
> diff -u -p -r1.75 interface.c
> --- usr.sbin/ospfd/interface.c 14 May 2012 10:17:21 -0000 1.75
> +++ usr.sbin/ospfd/interface.c 28 May 2015 11:31:58 -0000
> @@ -338,8 +338,10 @@ if_act_start(struct iface *iface)
> struct in_addr addr;
> struct timeval now;
>
> - if (!((iface->flags & IFF_UP) &&
> - LINK_STATE_IS_UP(iface->linkstate)))
> + if (!(iface->flags & IFF_UP) ||
> + (!LINK_STATE_IS_UP(iface->linkstate) &&
> + !(iface->media_type == IFT_CARP &&
> + iface->linkstate == LINK_STATE_DOWN)))
> return (0);
>
> if (iface->media_type == IFT_CARP && iface->passive == 0) {
> Index: usr.sbin/ospfd/kroute.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/ospfd/kroute.c,v
> retrieving revision 1.98
> diff -u -p -r1.98 kroute.c
> --- usr.sbin/ospfd/kroute.c 11 Feb 2015 05:57:44 -0000 1.98
> +++ usr.sbin/ospfd/kroute.c 28 May 2015 11:31:58 -0000
> @@ -1019,6 +1019,9 @@ if_change(u_short ifindex, int flags, st
> return;
> }
>
> + /* notify ospfe about interface link state */
> + main_imsg_compose_ospfe(IMSG_IFINFO, 0, kif, sizeof(struct kif));
> +
> reachable = (kif->flags & IFF_UP) &&
> LINK_STATE_IS_UP(kif->link_state);
>
> @@ -1026,9 +1029,6 @@ if_change(u_short ifindex, int flags, st
> return; /* nothing changed wrt nexthop validity */
>
> kif->nh_reachable = reachable;
> -
> - /* notify ospfe about interface link state */
> - main_imsg_compose_ospfe(IMSG_IFINFO, 0, kif, sizeof(struct kif));
>
> /* update redistribute list */
> RB_FOREACH(kr, kroute_tree, &krt) {
>
>