bfdd: update vrf of received packet

on vrf-lite environment, all incoming bfd packets are received by the
same socket on the default namespace. the vrfid is not relevant and
needs to be updated based on the incoming interface where traffic has
been received. If the traffic is received from an interface belonging to
a separate vrf, update the vrfid value accordingly.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
Philippe Guibert 2021-01-08 09:38:04 +00:00
parent 039c8158f3
commit 134a53ec48

View File

@ -543,6 +543,7 @@ int bfd_recv_cb(struct thread *t)
ifindex_t ifindex = IFINDEX_INTERNAL;
struct sockaddr_any local, peer;
uint8_t msgbuf[1516];
struct interface *ifp = NULL;
struct bfd_vrf_global *bvrf = THREAD_ARG(t);
vrfid = bvrf->vrf->vrf_id;
@ -572,6 +573,15 @@ int bfd_recv_cb(struct thread *t)
&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 */
if (mlen < BFD_PKT_LEN) {
cp_debug(is_mhop, &peer, &local, ifindex, vrfid,