bgpd: fix md5 set on listen sockets
* bgp_network.c: (bgp_md5_set) Missing piece from earlier listener change
did not get ported from Vyatta code into upstream. The list
listener_sockets changed from (int *) to (struct bgp_listener *).
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index 4cb6f7d..9e3427d 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -97,8 +97,8 @@
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 @@
/* 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. */