diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h index 5d04a9da9c1..37bc0c846d9 100644 --- a/sys/netinet/udp_var.h +++ b/sys/netinet/udp_var.h @@ -154,6 +154,9 @@ VNET_DECLARE(int, udp_log_in_vain); #define V_udp_blackhole VNET(udp_blackhole) #define V_udp_log_in_vain VNET(udp_log_in_vain) +VNET_DECLARE(int, zero_checksum_port); +#define V_zero_checksum_port VNET(zero_checksum_port) + static __inline struct inpcbinfo * udp_get_inpcbinfo(int protocol) { diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 535ebcd4530..32aa21cb24a 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -124,6 +124,11 @@ __FBSDID("$FreeBSD$"); #include +VNET_DEFINE(int, zero_checksum_port) = 0; +#define V_zero_checksum_port VNET(zero_checksum_port) +SYSCTL_INT(_net_inet6_udp6, OID_AUTO, rfc6935_port, CTLFLAG_VNET | CTLFLAG_RW, + &VNET_NAME(zero_checksum_port), 0, + "Zero UDP checksum allowed for traffic to/from this port."); /* * UDP protocol implementation. * Per RFC 768, August, 1980. @@ -267,7 +272,14 @@ udp6_input(struct mbuf **mp, int *offp, int proto) } if (uh->uh_sum == 0) { UDPSTAT_INC(udps_nosum); - goto badunlocked; + /* + * dport 0 was rejected earlier so this is OK even if + * zero_checksum_port is 0 (which is its default value). + */ + if (ntohs(uh->uh_dport) == V_zero_checksum_port) + goto skip_checksum; + else + goto badunlocked; } } @@ -287,6 +299,7 @@ udp6_input(struct mbuf **mp, int *offp, int proto) goto badunlocked; } +skip_checksum: /* * Construct sockaddr format source address. */