diff options
| author | Stephen Worley <sworley@nvidia.com> | 2022-11-15 11:46:27 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-15 11:46:27 -0500 |
| commit | 1ee3556e5f694dfebc538ed1b7ac501c9ee9547a (patch) | |
| tree | bd8233e87c060ab419e5ce3b1ecf0fe10b5bbc42 | |
| parent | 53317d66d1c435462335f76344faf8b34216a70a (diff) | |
| parent | b46fd5002938aa1c985ddf7af9ab22bd4c17c033 (diff) | |
Merge pull request #12291 from anlancs/pimd/mtrace-fd
pimd: delay creating the socket
| -rw-r--r-- | pimd/pim_igmp_mtrace.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/pimd/pim_igmp_mtrace.c b/pimd/pim_igmp_mtrace.c index 1a90b46dec..259c34c819 100644 --- a/pimd/pim_igmp_mtrace.c +++ b/pimd/pim_igmp_mtrace.c @@ -365,19 +365,9 @@ static int mtrace_un_forward_packet(struct pim_instance *pim, struct ip *ip_hdr, if (ip_hdr->ip_ttl-- <= 1) return -1; - ip_hdr->ip_sum = in_cksum(ip_hdr, ip_hdr->ip_hl * 4); - - fd = pim_socket_raw(IPPROTO_RAW); - - if (fd < 0) - return -1; - - pim_socket_ip_hdr(fd); - if (interface == NULL) { memset(&nexthop, 0, sizeof(nexthop)); if (!pim_nexthop_lookup(pim, &nexthop, ip_hdr->ip_dst, 0)) { - close(fd); if (PIM_DEBUG_MTRACE) zlog_debug( "Dropping mtrace packet, no route to destination"); @@ -389,6 +379,15 @@ static int mtrace_un_forward_packet(struct pim_instance *pim, struct ip *ip_hdr, if_out = interface; } + ip_hdr->ip_sum = in_cksum(ip_hdr, ip_hdr->ip_hl * 4); + + fd = pim_socket_raw(IPPROTO_RAW); + + if (fd < 0) + return -1; + + pim_socket_ip_hdr(fd); + ret = pim_socket_bind(fd, if_out); if (ret < 0) { |
