Skip to content

Commit

Permalink
Check VIF state also on ENETUNREACH
Browse files Browse the repository at this point in the history
Taking down an interface can on Linux also yield ENETUNREACH when
calling sendto().  We already check for ENETDOWN, this adds one
more case to check.

Signed-off-by: Joachim Wiberg <[email protected]>
  • Loading branch information
troglobit committed Oct 6, 2024
1 parent cf26305 commit e164a96
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/igmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,16 @@ void send_igmp(uint32_t src, uint32_t dst, int type, int code, uint32_t group, i

rc = sendto(igmp_socket, send_buf, len, 0, (struct sockaddr *)&sin, sizeof(sin));
if (rc < 0) {
if (errno == ENETDOWN)
switch (errno) {
case ENETUNREACH:
case ENETDOWN:
check_vif_state();
else
break;
default:
logit(igmp_log_level(type, code), errno, "sendto to %s on %s",
inet_fmt(dst, s1, sizeof(s1)), inet_fmt(src, s2, sizeof(s2)));
break;
}
}

if (setloop)
Expand Down
9 changes: 7 additions & 2 deletions src/ipip.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,16 @@ void send_ipip(uint32_t src, uint32_t dst, int type, int code, uint32_t group, i
msg.msg_iov = iov;
msg.msg_iovlen = 2;
if (sendmsg(raw_socket, &msg, 0) < 0) {
if (errno == ENETDOWN)
switch (errno) {
case ENETUNREACH:
case ENETDOWN:
check_vif_state();
else
break;
default:
logit(LOG_WARNING, errno, "sendmsg to %s on %s",
inet_fmt(sdst.sin_addr.s_addr, s1, sizeof(s1)), inet_fmt(src, s2, sizeof(s2)));
break;
}
}

IF_DEBUG(DEBUG_PKT|igmp_debug_kind(type, code))
Expand Down

0 comments on commit e164a96

Please sign in to comment.