]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pim6d: box out IPv4 fragmentation code
authorDavid Lamparter <equinox@opensourcerouting.org>
Mon, 28 Mar 2022 15:57:50 +0000 (17:57 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Mon, 28 Mar 2022 15:59:16 +0000 (17:59 +0200)
... 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>
pimd/pim_pim.c

index 3336a0e26b0a8cb491fd525b4287cd747a959530..50bbc0fe18f05574835292771e4e2930136c4f9e 100644 (file)
@@ -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,