From 968d3d40984d0279bce51259ce0e969adc7bda79 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 4 Jul 2011 14:37:25 -0700 Subject: [PATCH] Ignore carrier state on bridge device The carrier of bridge device reflects underlying devices in later kernels. Therefor RSTP daemon should ignore carrier (IFF_RUNNING) and only look at IFF_UP on bridge device. --- bridge_ctl.h | 2 +- bridge_track.c | 30 ++++++++++++++++++++---------- brmon.c | 7 +------ 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/bridge_ctl.h b/bridge_ctl.h index 2838330..b0449ca 100644 --- a/bridge_ctl.h +++ b/bridge_ctl.h @@ -33,7 +33,7 @@ void bridge_get_configuration(void); int bridge_set_state(int ifindex, int state); -int bridge_notify(int br_index, int if_index, int newlink, int up); +int bridge_notify(int br_index, int if_index, int newlink, unsigned flags); void bridge_bpdu_rcv(int ifindex, const unsigned char *data, int len); diff --git a/bridge_track.c b/bridge_track.c index efc23e5..289fc41 100644 --- a/bridge_track.c +++ b/bridge_track.c @@ -476,13 +476,14 @@ static void set_if_up(struct ifdata *ifc, int up) /*------------------------------------------------------------*/ -int bridge_notify(int br_index, int if_index, int newlink, int up) +int bridge_notify(int br_index, int if_index, int newlink, + unsigned flags) { - if (up) - up = 1; - LOG("br_index %d, if_index %d, up %d", br_index, if_index, up); - struct ifdata *br = NULL; + + LOG("br_index %d, if_index %d, up %d running %d", + br_index, if_index, (flags & IFF_UP), flags & IFF_RUNNING); + if (br_index >= 0) { br = find_if(br_index); if (br && !br->is_bridge) { @@ -536,6 +537,8 @@ int bridge_notify(int br_index, int if_index, int newlink, int up) delete_if(ifc); return 0; } + int up = (flags & (IFF_UP|IFF_RUNNING)) == (IFF_UP|IFF_RUNNING); + if (ifc->up != up) set_if_up(ifc, up); /* And speed and duplex */ } else { /* No br_index */ @@ -565,11 +568,18 @@ int bridge_notify(int br_index, int if_index, int newlink, int up) delete_if(ifc); return 0; } - if (ifc && ifc->up != up) { - if (ifc->is_bridge) - set_br_up(ifc, up); - else - set_if_up(ifc, up); + + if (ifc) { + if (ifc->is_bridge) { + int up = (flags & IFF_UP) != 0; + if (ifc->up != up) + set_br_up(ifc, up); + } else { + int up = (flags & (IFF_UP|IFF_RUNNING)) == (IFF_UP|IFF_RUNNING); + + if (ifc->up != up) + set_if_up(ifc, up); + } } } } diff --git a/brmon.c b/brmon.c index fd4dacd..4c4e490 100644 --- a/brmon.c +++ b/brmon.c @@ -30,11 +30,6 @@ static const char SNAPSHOT[] = "v0.1"; -static int is_up(const struct ifinfomsg *ifi) -{ - return (ifi->ifi_flags & IFF_UP) && (ifi->ifi_flags & IFF_RUNNING); -} - static int dump_msg(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) { @@ -95,7 +90,7 @@ static int dump_msg(const struct sockaddr_nl *who, struct nlmsghdr *n, bridge_notify(master, ifi->ifi_index, (n->nlmsg_type == RTM_NEWLINK), - is_up(ifi)); + ifi->ifi_flags); return 0; } -- 2.39.2