commit c5e716a8020ee487e3050b4e0f8229bfd0b441c8
Author: Alexander Zubkov <green@qrator.net>
Date:   Mon Jan 23 00:28:58 2023 +0100

    BGP: add local IP to lock key
    
    Teh lock for BGP session had only remote IP in its key. Thus multiple
    BGP sessions to the single remote IP from different local IPs were not
    possible. The patch adds local IP to the lock key so that such sessions
    can coexist and do not lock one another.

diff --git a/nest/locks.c b/nest/locks.c
index 812a6534..13c12b64 100644
--- a/nest/locks.c
+++ b/nest/locks.c
@@ -48,7 +48,8 @@ olock_same(struct object_lock *x, struct object_lock *y)
     x->vrf == y->vrf &&
     x->port == y->port &&
     x->inst == y->inst &&
-    ipa_equal(x->addr, y->addr);
+    ipa_equal(x->addr, y->addr) &&
+    ipa_equal(x->addr2, y->addr2);
 }
 
 static void
diff --git a/nest/locks.h b/nest/locks.h
index 37026c68..e98113e4 100644
--- a/nest/locks.h
+++ b/nest/locks.h
@@ -26,6 +26,7 @@
 struct object_lock {
   resource r;
   ip_addr addr;		/* Identification of a object: IP address */
+  ip_addr addr2;	/* ... second IP address (ex. local) */
   uint type;		/* ... object type (OBJLOCK_xxx) */
   uint port;		/* ... port number */
   uint inst;		/* ... instance ID */
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index 2e442e16..fca5a492 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -1570,6 +1570,7 @@ bgp_start(struct proto *P)
   struct object_lock *lock;
   lock = p->lock = olock_new(P->pool);
   lock->addr = p->remote_ip;
+  lock->addr2 = p->cf->local_ip;
   lock->port = p->cf->remote_port;
   lock->iface = p->cf->iface;
   lock->vrf = p->cf->iface ? NULL : p->p.vrf;
