pimd: log interface name for send errors

Not very helpful to be told only the fd number.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2022-03-12 22:41:41 +01:00
parent e576475723
commit 516b97fe4d

View File

@ -521,7 +521,8 @@ static uint16_t ip_id = 0;
static int pim_msg_send_frame(int fd, char *buf, size_t len, static int pim_msg_send_frame(int fd, char *buf, size_t len,
struct sockaddr *dst, size_t salen) struct sockaddr *dst, size_t salen,
const char *ifname)
{ {
struct ip *ip = (struct ip *)buf; struct ip *ip = (struct ip *)buf;
@ -537,8 +538,8 @@ static int pim_msg_send_frame(int fd, char *buf, size_t len,
ip->ip_len = htons(sendlen); ip->ip_len = htons(sendlen);
ip->ip_off = htons(offset | IP_MF); ip->ip_off = htons(offset | IP_MF);
if (pim_msg_send_frame(fd, buf, sendlen, dst, salen) if (pim_msg_send_frame(fd, buf, sendlen, dst, salen,
== 0) { ifname) == 0) {
struct ip *ip2 = (struct ip *)(buf + newlen1); struct ip *ip2 = (struct ip *)(buf + newlen1);
size_t newlen2 = len - sendlen; size_t newlen2 = len - sendlen;
sendlen = newlen2 + hdrsize; sendlen = newlen2 + hdrsize;
@ -547,7 +548,8 @@ static int pim_msg_send_frame(int fd, char *buf, size_t len,
ip2->ip_len = htons(sendlen); ip2->ip_len = htons(sendlen);
ip2->ip_off = htons(offset + (newlen1 >> 3)); ip2->ip_off = htons(offset + (newlen1 >> 3));
return pim_msg_send_frame(fd, (char *)ip2, return pim_msg_send_frame(fd, (char *)ip2,
sendlen, dst, salen); sendlen, dst, salen,
ifname);
} }
} }
@ -557,9 +559,9 @@ static int pim_msg_send_frame(int fd, char *buf, size_t len,
pim_inet4_dump("<dst?>", ip->ip_dst, dst_str, pim_inet4_dump("<dst?>", ip->ip_dst, dst_str,
sizeof(dst_str)); sizeof(dst_str));
zlog_warn( zlog_warn(
"%s: sendto() failure to %s: fd=%d msg_size=%zd: errno=%d: %s", "%s: sendto() failure to %s: iface=%s fd=%d msg_size=%zd: errno=%d: %s",
__func__, dst_str, fd, len, errno, __func__, dst_str, ifname, fd, len,
safe_strerror(errno)); errno, safe_strerror(errno));
} }
return -1; return -1;
} }
@ -641,7 +643,7 @@ int pim_msg_send(int fd, pim_addr src, pim_addr dst, uint8_t *pim_msg,
} }
pim_msg_send_frame(fd, (char *)buffer, sendlen, (struct sockaddr *)&to, pim_msg_send_frame(fd, (char *)buffer, sendlen, (struct sockaddr *)&to,
tolen); tolen, ifname);
return 0; return 0;
} }