summaryrefslogtreecommitdiffstats
path: root/pimd/pim_pim.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2022-03-28 17:57:50 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2022-03-28 17:59:16 +0200
commite7485deb0a21da3b371bfb71fd531056b356403b (patch)
treeaa9b5fd64e8a06deadcbedc602cbf036a6004987 /pimd/pim_pim.c
parentpim6d: include IPv6 pseudoheader in RX checksums (diff)
downloadfrr-e7485deb0a21da3b371bfb71fd531056b356403b.tar.xz
frr-e7485deb0a21da3b371bfb71fd531056b356403b.zip
pim6d: box out IPv4 fragmentation code
... this shouldn't run for IPv6. (We'll switch to not using IPV6_HDRINCL later, so the kernel will handle it, but for the time being let's just stop trying to use the IPv4 code for IPv6.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'pimd/pim_pim.c')
-rw-r--r--pimd/pim_pim.c74
1 files changed, 33 insertions, 41 deletions
diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c
index 3336a0e26..50bbc0fe1 100644
--- a/pimd/pim_pim.c
+++ b/pimd/pim_pim.c
@@ -557,50 +557,42 @@ static int pim_msg_send_frame(int fd, char *buf, size_t len,
struct sockaddr *dst, size_t salen,
const char *ifname)
{
- struct ip *ip = (struct ip *)buf;
-
- if (sendto(fd, buf, len, MSG_DONTWAIT, dst, salen) < 0) {
- char dst_str[INET_ADDRSTRLEN];
-
- switch (errno) {
- case EMSGSIZE: {
- size_t hdrsize = sizeof(struct ip);
- size_t newlen1 = ((len - hdrsize) / 2) & 0xFFF8;
- size_t sendlen = newlen1 + hdrsize;
- size_t offset = ntohs(ip->ip_off);
-
- ip->ip_len = htons(sendlen);
- ip->ip_off = htons(offset | IP_MF);
- if (pim_msg_send_frame(fd, buf, sendlen, dst, salen,
- ifname) == 0) {
- struct ip *ip2 = (struct ip *)(buf + newlen1);
- size_t newlen2 = len - sendlen;
- sendlen = newlen2 + hdrsize;
-
- memcpy(ip2, ip, hdrsize);
- ip2->ip_len = htons(sendlen);
- ip2->ip_off = htons(offset + (newlen1 >> 3));
- return pim_msg_send_frame(fd, (char *)ip2,
- sendlen, dst, salen,
- ifname);
- }
- }
+ if (sendto(fd, buf, len, MSG_DONTWAIT, dst, salen) >= 0)
+ return 0;
- return -1;
- default:
- if (PIM_DEBUG_PIM_PACKETS) {
- pim_inet4_dump("<dst?>", ip->ip_dst, dst_str,
- sizeof(dst_str));
- zlog_warn(
- "%s: sendto() failure to %s: iface=%s fd=%d msg_size=%zd: errno=%d: %s",
- __func__, dst_str, ifname, fd, len,
- errno, safe_strerror(errno));
- }
- return -1;
- }
+#if PIM_IPV == 4
+ if (errno == EMSGSIZE) {
+ struct ip *ip = (struct ip *)buf;
+ size_t hdrsize = sizeof(struct ip);
+ size_t newlen1 = ((len - hdrsize) / 2) & 0xFFF8;
+ size_t sendlen = newlen1 + hdrsize;
+ size_t offset = ntohs(ip->ip_off);
+ int ret;
+
+ ip->ip_len = htons(sendlen);
+ ip->ip_off = htons(offset | IP_MF);
+
+ ret = pim_msg_send_frame(fd, buf, sendlen, dst, salen, ifname);
+ if (ret)
+ return ret;
+
+ struct ip *ip2 = (struct ip *)(buf + newlen1);
+ size_t newlen2 = len - sendlen;
+
+ sendlen = newlen2 + hdrsize;
+
+ memcpy(ip2, ip, hdrsize);
+ ip2->ip_len = htons(sendlen);
+ ip2->ip_off = htons(offset + (newlen1 >> 3));
+ return pim_msg_send_frame(fd, (char *)ip2, sendlen, dst, salen,
+ ifname);
}
+#endif
- return 0;
+ zlog_warn(
+ "%s: sendto() failure to %pSU: iface=%s fd=%d msg_size=%zd: %m",
+ __func__, dst, ifname, fd, len);
+ return -1;
}
int pim_msg_send(int fd, pim_addr src, pim_addr dst, uint8_t *pim_msg,