summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pimd/pim_msdp.c12
-rw-r--r--pimd/pim_msdp.h3
-rw-r--r--pimd/pim_msdp_socket.c29
3 files changed, 21 insertions, 23 deletions
diff --git a/pimd/pim_msdp.c b/pimd/pim_msdp.c
index 215cc3c50..bea74ff7d 100644
--- a/pimd/pim_msdp.c
+++ b/pimd/pim_msdp.c
@@ -1012,16 +1012,6 @@ void pim_msdp_peer_pkt_txed(struct pim_msdp_peer *mp)
}
}
-static void pim_msdp_addr2su(union sockunion *su, struct in_addr addr)
-{
- sockunion_init(su);
- su->sin.sin_addr = addr;
- su->sin.sin_family = AF_INET;
-#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
- su->sin.sin_len = sizeof(struct sockaddr_in);
-#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
-}
-
/* 11.2.A1: create a new peer and transition state to listen or connecting */
struct pim_msdp_peer *pim_msdp_peer_add(struct pim_instance *pim,
const struct in_addr *peer,
@@ -1037,11 +1027,9 @@ struct pim_msdp_peer *pim_msdp_peer_add(struct pim_instance *pim,
mp->pim = pim;
mp->peer = *peer;
pim_inet4_dump("<peer?>", mp->peer, mp->key_str, sizeof(mp->key_str));
- pim_msdp_addr2su(&mp->su_peer, mp->peer);
mp->local = *local;
/* XXX: originator_id setting needs to move to the mesh group */
pim->msdp.originator_id = *local;
- pim_msdp_addr2su(&mp->su_local, mp->local);
if (mesh_group_name)
mp->mesh_group_name =
XSTRDUP(MTYPE_PIM_MSDP_MG_NAME, mesh_group_name);
diff --git a/pimd/pim_msdp.h b/pimd/pim_msdp.h
index f77b0e1a3..f01f575e0 100644
--- a/pimd/pim_msdp.h
+++ b/pimd/pim_msdp.h
@@ -114,9 +114,6 @@ struct pim_msdp_peer {
enum pim_msdp_peer_state state;
enum pim_msdp_peer_flags flags;
- /* TCP socket info */
- union sockunion su_local;
- union sockunion su_peer;
int fd;
/* protocol timers */
diff --git a/pimd/pim_msdp_socket.c b/pimd/pim_msdp_socket.c
index 2fb0bb87c..b29993304 100644
--- a/pimd/pim_msdp_socket.c
+++ b/pimd/pim_msdp_socket.c
@@ -49,6 +49,16 @@ static void pim_msdp_update_sock_send_buffer_size(int fd)
}
}
+static void pim_msdp_addr2su(union sockunion *su, struct in_addr addr)
+{
+ sockunion_init(su);
+ su->sin.sin_addr = addr;
+ su->sin.sin_family = AF_INET;
+#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
+ su->sin.sin_len = sizeof(struct sockaddr_in);
+#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
+}
+
/**
* Helper function to reduce code duplication.
*
@@ -64,7 +74,6 @@ static int _pim_msdp_sock_listen(const struct vrf *vrf,
int rv;
socklen_t socklen;
struct sockaddr_in sin = {};
- union sockunion su_peer = {};
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == -1) {
@@ -117,7 +126,9 @@ static int _pim_msdp_sock_listen(const struct vrf *vrf,
/* Set MD5 authentication. */
if (mp && mp->auth_key) {
- su_peer = mp->su_peer;
+ union sockunion su_peer = {};
+
+ pim_msdp_addr2su(&su_peer, mp->peer);
frr_with_privs (&pimd_privs) {
sockopt_tcp_signature(sock, &su_peer, mp->auth_key);
}
@@ -349,6 +360,7 @@ int pim_msdp_sock_listen(struct pim_instance *pim)
int pim_msdp_sock_connect(struct pim_msdp_peer *mp)
{
int rc;
+ union sockunion su_peer = {}, su_local = {};
if (PIM_DEBUG_MSDP_INTERNAL) {
zlog_debug("MSDP peer %s attempt connect%s", mp->key_str,
@@ -366,8 +378,11 @@ int pim_msdp_sock_connect(struct pim_msdp_peer *mp)
pim_msdp_peer_stop_tcp_conn(mp, false /* chg_state */);
}
+ pim_msdp_addr2su(&su_peer, mp->peer);
+ pim_msdp_addr2su(&su_local, mp->local);
+
/* Make socket for the peer. */
- mp->fd = sockunion_socket(&mp->su_peer);
+ mp->fd = sockunion_socket(&su_peer);
if (mp->fd < 0) {
flog_err_sys(EC_LIB_SOCKET,
"pim_msdp_socket socket failure: %s",
@@ -402,7 +417,7 @@ int pim_msdp_sock_connect(struct pim_msdp_peer *mp)
sockopt_reuseport(mp->fd);
/* source bind */
- rc = sockunion_bind(mp->fd, &mp->su_local, 0, &mp->su_local);
+ rc = sockunion_bind(mp->fd, &su_local, 0, &su_local);
if (rc < 0) {
flog_err_sys(EC_LIB_SOCKET,
"pim_msdp_socket connect bind failure: %s",
@@ -421,12 +436,10 @@ int pim_msdp_sock_connect(struct pim_msdp_peer *mp)
/* Set authentication (if configured). */
if (mp->auth_key) {
frr_with_privs (&pimd_privs) {
- sockopt_tcp_signature(mp->fd, &mp->su_peer,
- mp->auth_key);
+ sockopt_tcp_signature(mp->fd, &su_peer, mp->auth_key);
}
}
/* Connect to the remote mp. */
- return (sockunion_connect(mp->fd, &mp->su_peer,
- htons(PIM_MSDP_TCP_PORT), 0));
+ return (sockunion_connect(mp->fd, &su_peer, htons(PIM_MSDP_TCP_PORT), 0));
}