From bc8a0a925435b4b02a95ab531b6505f425ce8239 Mon Sep 17 00:00:00 2001 From: kevinshen Date: Mon, 6 Jun 2022 11:27:22 +0800 Subject: [PATCH] fix bgp local router-id selected error Root cause: loopback interface is created by "ip link add XXX type dummy"; however, IFF_LOOPBACK flag is not set Solution: check interface name prefix (Loopback) to let zebra use sorted rid_lo list instead of rid_all list --- lib/if.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) mode change 100644 => 100755 lib/if.c diff --git a/lib/if.c b/lib/if.c old mode 100644 new mode 100755 index 86b850c059..17b7c93a61 --- a/lib/if.c +++ b/lib/if.c @@ -475,7 +475,14 @@ int if_is_loopback(const struct interface *ifp) /* XXX: Do this better, eg what if IFF_WHATEVER means X on platform M * but Y on platform N? */ - return (ifp->flags & (IFF_LOOPBACK | IFF_NOXMIT | IFF_VIRTUAL)); +#define INSPUR_LO_STR "Loopback" + bool is_lo = false; + if (strlen(INSPUR_LO_STR) <= strlen(ifp->name)) { + if (!strncmp(INSPUR_LO_STR, ifp->name, strlen(INSPUR_LO_STR))) + is_lo = true; + } + + return is_lo | (ifp->flags & (IFF_LOOPBACK | IFF_NOXMIT | IFF_VIRTUAL)); } /* Check interface is VRF */