On Fri, Oct 26, 2018 at 12:03:57PM +0200, Alexander Zubkov wrote:
> BGP protocol could not bind to the interface in a VRF
> even if the vrf option was specified in the configuration.

Hi

Thanks for the bugfix, but note that in order to work with multiple BGP
protocols in different VRFs, also the selector of existing sockets that
runs before the sk_new() have to take it into consideration, otherwise it
will just return old socket bound to different VRF. See attached patch.

-- 
Elen sila lumenn' omentielvo

Ondrej 'Santiago' Zajicek (email: santi...@crfreenet.org)
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."
commit e19d08055a4614f03e51ee72617be10946ce7919
Author: Ondrej Zajicek (work) <santi...@crfreenet.org>
Date:   Fri Oct 26 19:11:33 2018 +0200

    BGP: Fix VRF for listening socket
    
    Listening socket should be bound to specified interface and VRF.
    
    Thanks to Alexander Zubkov for the bugreport.

diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index e7479df7..e2a57137 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -159,7 +159,8 @@ bgp_open(struct bgp_proto *p)
   /* We assume that cf->iface is defined iff cf->local_ip is link-local */
 
   WALK_LIST(bs, bgp_sockets)
-    if (ipa_equal(bs->sk->saddr, addr) && (bs->sk->iface == ifa) && (bs->sk->sport == port))
+    if (ipa_equal(bs->sk->saddr, addr) && (bs->sk->sport == port) &&
+	(bs->sk->iface == ifa) && (bs->sk->vrf == p->p.vrf))
     {
       bs->uc++;
       p->sock = bs;
@@ -171,6 +172,8 @@ bgp_open(struct bgp_proto *p)
   sk->ttl = 255;
   sk->saddr = addr;
   sk->sport = port;
+  sk->iface = ifa;
+  sk->vrf = p->p.vrf;
   sk->flags = 0;
   sk->tos = IP_PREC_INTERNET_CONTROL;
   sk->rbsize = BGP_RX_BUFFER_SIZE;

Reply via email to