[PATCH 2/2] Added support for carp validation on BSD
--- sysdep/bsd/Modules | 1 + sysdep/bsd/krt-sock.c | 10 ++++++++-- sysdep/bsd/krt-sock.h | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sysdep/bsd/Modules b/sysdep/bsd/Modules index 84abffd..5af82ee 100644 --- a/sysdep/bsd/Modules +++ b/sysdep/bsd/Modules @@ -4,3 +4,4 @@ sysio.h krt-set.h krt-sock.c krt-sock.h +check_carp.c diff --git a/sysdep/bsd/krt-sock.c b/sysdep/bsd/krt-sock.c index 4bf6600..671c96f 100644 --- a/sysdep/bsd/krt-sock.c +++ b/sysdep/bsd/krt-sock.c @@ -458,8 +458,14 @@ krt_read_ifinfo(struct ks_msg *msg) f.mtu = ifm->ifm_data.ifi_mtu; f.flags = 0; - if (fl & IFF_UP) - f.flags |= IF_ADMIN_UP; + int carp = check_carp(f.name, strlen(f.name)); + if (carp < 0) //no carp interface + if (fl & IFF_UP) + f.flags |= IF_ADMIN_UP; + else + if (fl & IFF_UP && carp == 2) // (interface) carp is master and only then should the interface be up. + f.flags |= IF_ADMIN_UP; + if (ifm->ifm_data.ifi_link_state != LINK_STATE_DOWN) f.flags |= IF_LINK_UP; /* up or unknown */ if (fl & IFF_LOOPBACK) /* Loopback */ diff --git a/sysdep/bsd/krt-sock.h b/sysdep/bsd/krt-sock.h index aab639c..d836709 100644 --- a/sysdep/bsd/krt-sock.h +++ b/sysdep/bsd/krt-sock.h @@ -39,4 +39,6 @@ static inline void krt_set_copy_params(struct krt_set_params *d UNUSED, struct k void krt_read_msg(struct proto *p, struct ks_msg *msg, int scan); +int check_carp(const char *name, int namelen); + #endif -- 1.7.3.5 --------------010500000801000408070709--
participants (1)
-
Fredrik Danerklint