]> git.puffer.fish Git - mirror/frr.git/commitdiff
bfdd: update vrf of received packet
authorPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 8 Jan 2021 09:38:04 +0000 (09:38 +0000)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Sat, 9 Jan 2021 13:29:45 +0000 (13:29 +0000)
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>
bfdd/bfd_packet.c

index 10b99a62a97d5e944533dce73c6b97e5e02ac86f..076318e6cae2857f200377fe98e64a32be434e57 100644 (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,