Skip to content

Commit a7af6f6

Browse files
fix: Handle ENOPROTOOPT for IPV6_HDRINCL
1 parent 1eb5cfa commit a7af6f6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/rawsock.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,13 @@ int fh_rawsock_setup(int af)
5858
opt = 1;
5959
res = setsockopt(sock_fd, IPPROTO_IPV6, IPV6_HDRINCL, &opt,
6060
sizeof(opt));
61-
if (res < 0) {
61+
if (res < 0 && errno != ENOPROTOOPT) {
62+
/*
63+
ENOPROTOOPT may occur when kernel version < 4.5.
64+
However, on Linux, IPPROTO_RAW means the kernel will not add a
65+
Layer 3 header, so it is safe to ignore this error.
66+
See raw(7) for details.
67+
*/
6268
E("ERROR: setsockopt(): IPV6_HDRINCL: %s", strerror(errno));
6369
goto close_socket;
6470
}

0 commit comments

Comments
 (0)