summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_network.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index 4cb6f7d8..9e3427d2 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -97,8 +97,8 @@ int
bgp_md5_set (struct peer *peer)
{
struct listnode *node;
- int fret = 0, ret;
- int *socket;
+ int ret = 0;
+ struct bgp_listener *listener;
if ( bgpd_privs.change (ZPRIVS_RAISE) )
{
@@ -109,16 +109,17 @@ bgp_md5_set (struct peer *peer)
/* Just set the password on the listen socket(s). Outbound connections
* are taken care of in bgp_connect() below.
*/
- for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, socket))
- {
- ret = bgp_md5_set_socket ((int)(long)socket, &peer->su, peer->password);
- if (ret < 0)
- fret = ret;
- }
+ for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, listener))
+ if (listener->su.sa.sa_family == peer->su.sa.sa_family)
+ {
+ ret = bgp_md5_set_socket (listener->fd, &peer->su, peer->password);
+ break;
+ }
+
if (bgpd_privs.change (ZPRIVS_LOWER) )
zlog_err ("%s: could not lower privs", __func__);
- return fret;
+ return ret;
}
/* Accept bgp connection. */