mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-11 10:54:01 +00:00
Merge pull request #7840 from pguibert6WIND/bfd_misc_fixes_vrflite
Bfd misc fixes
This commit is contained in:
commit
af05c8951c
13
bfdd/bfd.c
13
bfdd/bfd.c
@ -313,6 +313,13 @@ int bfd_session_enable(struct bfd_session *bs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!vrf_is_backend_netns() && vrf && vrf->vrf_id != VRF_DEFAULT
|
||||||
|
&& !if_lookup_by_name(vrf->name, vrf->vrf_id)) {
|
||||||
|
zlog_err("session-enable: vrf interface %s not available yet",
|
||||||
|
vrf->name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (bs->key.ifname[0]) {
|
if (bs->key.ifname[0]) {
|
||||||
if (vrf)
|
if (vrf)
|
||||||
ifp = if_lookup_by_name(bs->key.ifname, vrf->vrf_id);
|
ifp = if_lookup_by_name(bs->key.ifname, vrf->vrf_id);
|
||||||
@ -320,14 +327,16 @@ int bfd_session_enable(struct bfd_session *bs)
|
|||||||
ifp = if_lookup_by_name_all_vrf(bs->key.ifname);
|
ifp = if_lookup_by_name_all_vrf(bs->key.ifname);
|
||||||
if (ifp == NULL) {
|
if (ifp == NULL) {
|
||||||
zlog_err(
|
zlog_err(
|
||||||
"session-enable: specified interface doesn't exists.");
|
"session-enable: specified interface %s (VRF %s) doesn't exist.",
|
||||||
|
bs->key.ifname, vrf ? vrf->name : "<all>");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (bs->key.ifname[0] && !vrf) {
|
if (bs->key.ifname[0] && !vrf) {
|
||||||
vrf = vrf_lookup_by_id(ifp->vrf_id);
|
vrf = vrf_lookup_by_id(ifp->vrf_id);
|
||||||
if (vrf == NULL) {
|
if (vrf == NULL) {
|
||||||
zlog_err(
|
zlog_err(
|
||||||
"session-enable: specified VRF doesn't exists.");
|
"session-enable: specified VRF %u doesn't exist.",
|
||||||
|
ifp->vrf_id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -543,6 +543,7 @@ int bfd_recv_cb(struct thread *t)
|
|||||||
ifindex_t ifindex = IFINDEX_INTERNAL;
|
ifindex_t ifindex = IFINDEX_INTERNAL;
|
||||||
struct sockaddr_any local, peer;
|
struct sockaddr_any local, peer;
|
||||||
uint8_t msgbuf[1516];
|
uint8_t msgbuf[1516];
|
||||||
|
struct interface *ifp = NULL;
|
||||||
struct bfd_vrf_global *bvrf = THREAD_ARG(t);
|
struct bfd_vrf_global *bvrf = THREAD_ARG(t);
|
||||||
|
|
||||||
vrfid = bvrf->vrf->vrf_id;
|
vrfid = bvrf->vrf->vrf_id;
|
||||||
@ -572,6 +573,15 @@ int bfd_recv_cb(struct thread *t)
|
|||||||
&local, &peer);
|
&local, &peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* update vrf-id because when in vrf-lite mode,
|
||||||
|
* the socket is on default namespace
|
||||||
|
*/
|
||||||
|
if (ifindex) {
|
||||||
|
ifp = if_lookup_by_index(ifindex, vrfid);
|
||||||
|
if (ifp)
|
||||||
|
vrfid = ifp->vrf_id;
|
||||||
|
}
|
||||||
|
|
||||||
/* Implement RFC 5880 6.8.6 */
|
/* Implement RFC 5880 6.8.6 */
|
||||||
if (mlen < BFD_PKT_LEN) {
|
if (mlen < BFD_PKT_LEN) {
|
||||||
cp_debug(is_mhop, &peer, &local, ifindex, vrfid,
|
cp_debug(is_mhop, &peer, &local, ifindex, vrfid,
|
||||||
@ -951,8 +961,9 @@ int bp_peer_socket(const struct bfd_session *bs)
|
|||||||
|
|
||||||
if (bs->key.ifname[0])
|
if (bs->key.ifname[0])
|
||||||
device_to_bind = (const char *)bs->key.ifname;
|
device_to_bind = (const char *)bs->key.ifname;
|
||||||
else if (CHECK_FLAG(bs->flags, BFD_SESS_FLAG_MH)
|
else if ((!vrf_is_backend_netns() && bs->vrf->vrf_id != VRF_DEFAULT)
|
||||||
&& bs->key.vrfname[0])
|
|| ((CHECK_FLAG(bs->flags, BFD_SESS_FLAG_MH)
|
||||||
|
&& bs->key.vrfname[0])))
|
||||||
device_to_bind = (const char *)bs->key.vrfname;
|
device_to_bind = (const char *)bs->key.vrfname;
|
||||||
|
|
||||||
frr_with_privs(&bglobal.bfdd_privs) {
|
frr_with_privs(&bglobal.bfdd_privs) {
|
||||||
@ -1018,8 +1029,9 @@ int bp_peer_socketv6(const struct bfd_session *bs)
|
|||||||
|
|
||||||
if (bs->key.ifname[0])
|
if (bs->key.ifname[0])
|
||||||
device_to_bind = (const char *)bs->key.ifname;
|
device_to_bind = (const char *)bs->key.ifname;
|
||||||
else if (CHECK_FLAG(bs->flags, BFD_SESS_FLAG_MH)
|
else if ((!vrf_is_backend_netns() && bs->vrf->vrf_id != VRF_DEFAULT)
|
||||||
&& bs->key.vrfname[0])
|
|| ((CHECK_FLAG(bs->flags, BFD_SESS_FLAG_MH)
|
||||||
|
&& bs->key.vrfname[0])))
|
||||||
device_to_bind = (const char *)bs->key.vrfname;
|
device_to_bind = (const char *)bs->key.vrfname;
|
||||||
|
|
||||||
frr_with_privs(&bglobal.bfdd_privs) {
|
frr_with_privs(&bglobal.bfdd_privs) {
|
||||||
|
@ -669,17 +669,24 @@ static void bfdd_sessions_enable_interface(struct interface *ifp)
|
|||||||
struct bfd_session *bs;
|
struct bfd_session *bs;
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
|
|
||||||
|
vrf = vrf_lookup_by_id(ifp->vrf_id);
|
||||||
|
if (!vrf)
|
||||||
|
return;
|
||||||
|
|
||||||
TAILQ_FOREACH(bso, &bglobal.bg_obslist, bso_entry) {
|
TAILQ_FOREACH(bso, &bglobal.bg_obslist, bso_entry) {
|
||||||
bs = bso->bso_bs;
|
bs = bso->bso_bs;
|
||||||
/* Interface name mismatch. */
|
/* check vrf name */
|
||||||
if (strcmp(ifp->name, bs->key.ifname))
|
|
||||||
continue;
|
|
||||||
vrf = vrf_lookup_by_id(ifp->vrf_id);
|
|
||||||
if (!vrf)
|
|
||||||
continue;
|
|
||||||
if (bs->key.vrfname[0] &&
|
if (bs->key.vrfname[0] &&
|
||||||
strcmp(vrf->name, bs->key.vrfname))
|
strcmp(vrf->name, bs->key.vrfname))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* If Interface matches vrfname, then bypass iface check */
|
||||||
|
if (vrf_is_backend_netns() || strcmp(ifp->name, vrf->name)) {
|
||||||
|
/* Interface name mismatch. */
|
||||||
|
if (strcmp(ifp->name, bs->key.ifname))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* Skip enabled sessions. */
|
/* Skip enabled sessions. */
|
||||||
if (bs->sock != -1)
|
if (bs->sock != -1)
|
||||||
continue;
|
continue;
|
||||||
@ -759,7 +766,8 @@ void bfdd_sessions_disable_vrf(struct vrf *vrf)
|
|||||||
static int bfd_ifp_destroy(struct interface *ifp)
|
static int bfd_ifp_destroy(struct interface *ifp)
|
||||||
{
|
{
|
||||||
if (bglobal.debug_zebra)
|
if (bglobal.debug_zebra)
|
||||||
zlog_debug("zclient: delete interface %s", ifp->name);
|
zlog_debug("zclient: delete interface %s (VRF %u)", ifp->name,
|
||||||
|
ifp->vrf_id);
|
||||||
|
|
||||||
bfdd_sessions_disable_interface(ifp);
|
bfdd_sessions_disable_interface(ifp);
|
||||||
|
|
||||||
@ -812,10 +820,10 @@ static int bfdd_interface_address_update(ZAPI_CALLBACK_ARGS)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (bglobal.debug_zebra)
|
if (bglobal.debug_zebra)
|
||||||
zlog_debug("zclient: %s local address %pFX",
|
zlog_debug("zclient: %s local address %pFX (VRF %u)",
|
||||||
cmd == ZEBRA_INTERFACE_ADDRESS_ADD ? "add"
|
cmd == ZEBRA_INTERFACE_ADDRESS_ADD ? "add"
|
||||||
: "delete",
|
: "delete",
|
||||||
ifc->address);
|
ifc->address, vrf_id);
|
||||||
|
|
||||||
if (cmd == ZEBRA_INTERFACE_ADDRESS_ADD)
|
if (cmd == ZEBRA_INTERFACE_ADDRESS_ADD)
|
||||||
bfdd_sessions_enable_address(ifc);
|
bfdd_sessions_enable_address(ifc);
|
||||||
@ -828,8 +836,8 @@ static int bfdd_interface_address_update(ZAPI_CALLBACK_ARGS)
|
|||||||
static int bfd_ifp_create(struct interface *ifp)
|
static int bfd_ifp_create(struct interface *ifp)
|
||||||
{
|
{
|
||||||
if (bglobal.debug_zebra)
|
if (bglobal.debug_zebra)
|
||||||
zlog_debug("zclient: add interface %s", ifp->name);
|
zlog_debug("zclient: add interface %s (VRF %u)", ifp->name,
|
||||||
|
ifp->vrf_id);
|
||||||
bfdd_sessions_enable_interface(ifp);
|
bfdd_sessions_enable_interface(ifp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user