From 01d8acff73d92e9c6db47428691d5cec2ac09cd3 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 29 Oct 2020 06:55:04 -0400 Subject: [PATCH 1/3] ospf6d: Clean up ospf6_network.h header Make it compliant. Signed-off-by: Donald Sharp --- ospf6d/ospf6_network.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ospf6d/ospf6_network.h b/ospf6d/ospf6_network.h index d11a611c49..ebd8271175 100644 --- a/ospf6d/ospf6_network.h +++ b/ospf6d/ospf6_network.h @@ -28,9 +28,11 @@ extern int ospf6_serv_sock(struct ospf6 *ospf6); extern void ospf6_serv_close(int *ospf6_sock); extern int ospf6_sso(ifindex_t ifindex, struct in6_addr *group, int option); -extern int ospf6_sendmsg(struct in6_addr *, struct in6_addr *, ifindex_t *, - struct iovec *, int ospf6_sock); -extern int ospf6_recvmsg(struct in6_addr *, struct in6_addr *, ifindex_t *, - struct iovec *, int ospf6_sock); +extern int ospf6_sendmsg(struct in6_addr *src, struct in6_addr *dst, + ifindex_t *ifindex, struct iovec *message, + int ospf6_sock); +extern int ospf6_recvmsg(struct in6_addr *src, struct in6_addr *dst, + ifindex_t *ifindex, struct iovec *message, + int ospf6_sock); #endif /* OSPF6_NETWORK_H */ From b66ec22ca9b227c4b7f78f71918be7eff30fb552 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 29 Oct 2020 06:59:42 -0400 Subject: [PATCH 2/3] ospf6d: ifindex should not be a pointer for ospf6_sendmsg Let's cleanup the ospf6_sendmsg api and not pass in a pointer to the ifindex to use. It's an integer. Also remove the assert(*ifindex); We never use ifindex of 0 Signed-off-by: Donald Sharp --- ospf6d/ospf6_message.c | 2 +- ospf6d/ospf6_network.c | 9 ++++----- ospf6d/ospf6_network.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c index 07089d8774..853e2714cb 100644 --- a/ospf6d/ospf6_message.c +++ b/ospf6d/ospf6_message.c @@ -1701,7 +1701,7 @@ static void ospf6_send(struct in6_addr *src, struct in6_addr *dst, /* send message */ if (oi->area->ospf6->fd != -1) { - len = ospf6_sendmsg(src, dst, &oi->interface->ifindex, iovector, + len = ospf6_sendmsg(src, dst, oi->interface->ifindex, iovector, oi->area->ospf6->fd); if (len != ntohs(oh->length)) flog_err(EC_LIB_DEVELOPMENT, diff --git a/ospf6d/ospf6_network.c b/ospf6d/ospf6_network.c index 6c83881bf4..43b6d08b54 100644 --- a/ospf6d/ospf6_network.c +++ b/ospf6d/ospf6_network.c @@ -171,7 +171,7 @@ static int iov_totallen(struct iovec *iov) } int ospf6_sendmsg(struct in6_addr *src, struct in6_addr *dst, - ifindex_t *ifindex, struct iovec *message, int ospf6_sock) + ifindex_t ifindex, struct iovec *message, int ospf6_sock) { int retval; struct msghdr smsghdr; @@ -184,7 +184,6 @@ int ospf6_sendmsg(struct in6_addr *src, struct in6_addr *dst, struct sockaddr_in6 dst_sin6; assert(dst); - assert(*ifindex); memset(&cmsgbuf, 0, sizeof(cmsgbuf)); scmsgp = (struct cmsghdr *)&cmsgbuf; @@ -192,7 +191,7 @@ int ospf6_sendmsg(struct in6_addr *src, struct in6_addr *dst, memset(&dst_sin6, 0, sizeof(struct sockaddr_in6)); /* source address */ - pktinfo->ipi6_ifindex = *ifindex; + pktinfo->ipi6_ifindex = ifindex; if (src) memcpy(&pktinfo->ipi6_addr, src, sizeof(struct in6_addr)); else @@ -204,7 +203,7 @@ int ospf6_sendmsg(struct in6_addr *src, struct in6_addr *dst, dst_sin6.sin6_len = sizeof(struct sockaddr_in6); #endif /*SIN6_LEN*/ memcpy(&dst_sin6.sin6_addr, dst, sizeof(struct in6_addr)); - dst_sin6.sin6_scope_id = *ifindex; + dst_sin6.sin6_scope_id = ifindex; /* send control msg */ scmsgp->cmsg_level = IPPROTO_IPV6; @@ -223,7 +222,7 @@ int ospf6_sendmsg(struct in6_addr *src, struct in6_addr *dst, retval = sendmsg(ospf6_sock, &smsghdr, 0); if (retval != iov_totallen(message)) - zlog_warn("sendmsg failed: ifindex: %d: %s (%d)", *ifindex, + zlog_warn("sendmsg failed: ifindex: %d: %s (%d)", ifindex, safe_strerror(errno), errno); return retval; diff --git a/ospf6d/ospf6_network.h b/ospf6d/ospf6_network.h index ebd8271175..0ec7975e14 100644 --- a/ospf6d/ospf6_network.h +++ b/ospf6d/ospf6_network.h @@ -29,7 +29,7 @@ extern void ospf6_serv_close(int *ospf6_sock); extern int ospf6_sso(ifindex_t ifindex, struct in6_addr *group, int option); extern int ospf6_sendmsg(struct in6_addr *src, struct in6_addr *dst, - ifindex_t *ifindex, struct iovec *message, + ifindex_t ifindex, struct iovec *message, int ospf6_sock); extern int ospf6_recvmsg(struct in6_addr *src, struct in6_addr *dst, ifindex_t *ifindex, struct iovec *message, From 130830323d4aeed973a56f6982ef7a112bc01d80 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 29 Oct 2020 08:53:43 -0400 Subject: [PATCH 3/3] ospf6d: Give a bit more data when sendmsg fails When sendmsg fails add a bit more data in hopes we can figure out what is going wrong. Signed-off-by: Donald Sharp --- ospf6d/ospf6_network.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ospf6d/ospf6_network.c b/ospf6d/ospf6_network.c index 43b6d08b54..94e80b0f28 100644 --- a/ospf6d/ospf6_network.c +++ b/ospf6d/ospf6_network.c @@ -222,7 +222,8 @@ int ospf6_sendmsg(struct in6_addr *src, struct in6_addr *dst, retval = sendmsg(ospf6_sock, &smsghdr, 0); if (retval != iov_totallen(message)) - zlog_warn("sendmsg failed: ifindex: %d: %s (%d)", ifindex, + zlog_warn("sendmsg failed: source: %pI6 Dest: %pI6 ifindex: %d: %s (%d)", + src, dst, ifindex, safe_strerror(errno), errno); return retval;