From 017a7d32fe67b52080826458adf30a6e5f07692f Mon Sep 17 00:00:00 2001
From: Benjamin Cama <benoar@dolka.fr>
Date: Mon, 8 Aug 2011 00:33:36 +0200
Subject: [PATCH 1/1] Use the source IP we use as BGP router identifier.

Signed-off-by: Benjamin Cama <benoar@dolka.fr>
---
 bgp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/bgp.c b/bgp.c
index 4a4bea0..bfcb86e 100644
--- a/bgp.c
+++ b/bgp.c
@@ -1361,7 +1361,11 @@ static int bgp_send_open(struct bgp_peer *peer)
     data.version = BGP_VERSION;
     data.as = htons(our_as);
     data.hold_time = htons(peer->hold);
-    data.identifier = my_address;
+    /* use the source IP we use as identifier, if available */
+    if (peer->source_addr != INADDR_ANY)
+	data.identifier = peer->source_addr;
+    else
+	data.identifier = my_address;
 
     /* if we know peer doesn't support MP (mp_handling == DoesntHandleIPv6Routes)
        then don't add this parameter */
-- 
2.20.1