diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 1a594cd1b68..9ebbf9826ef 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -601,7 +601,8 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, } m->m_pkthdr.csum_flags |= CSUM_IP; - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA & ~ifp->if_hwassist) { + if ((m->m_pkthdr.csum_flags & CSUM_DELAY_DATA & ~ifp->if_hwassist) || + (m->m_pkthdr.csum_flags & CSUM_UDP_TRAIL)) { in_delayed_cksum(m); m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 670182ece8b..7ce3f78ed88 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -140,6 +140,12 @@ u_long udp_recvspace = 40 * (1024 + SYSCTL_ULONG(_net_inet_udp, UDPCTL_RECVSPACE, recvspace, CTLFLAG_RW, &udp_recvspace, 0, "Maximum space for incoming UDP datagrams"); +VNET_DEFINE(int, udp_trailing_data) = 0; +SYSCTL_INT(_net_inet_udp, OID_AUTO, udp_trailing_data, CTLFLAG_VNET | CTLFLAG_RW, + &VNET_NAME(udp_trailing_data), 0, + "dirty hack - send udp trailing data"); +#define V_udp_trailing_data VNET(udp_trailing_data) + VNET_DEFINE(struct inpcbhead, udb); /* from udp_var.h */ VNET_DEFINE(struct inpcbinfo, udbinfo); VNET_DEFINE(struct inpcbhead, ulitecb); @@ -1460,7 +1466,13 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, m->m_pkthdr.csum_flags = CSUM_UDP; m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); } - ((struct ip *)ui)->ip_len = htons(sizeof(struct udpiphdr) + len); + if (V_udp_trailing_data) { + u_char *trailer = "freebsd"; + m_append(m, sizeof(trailer), trailer); + ((struct ip *)ui)->ip_len = htons(sizeof(struct udpiphdr) + len + sizeof(trailer)); + m->m_pkthdr.csum_flags |= CSUM_UDP_TRAIL; + } else + ((struct ip *)ui)->ip_len = htons(sizeof(struct udpiphdr) + len); ((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; /* XXX */ ((struct ip *)ui)->ip_tos = tos; /* XXX */ UDPSTAT_INC(udps_opackets); diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 81aed4e75f8..3265ea6c278 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -503,6 +503,7 @@ struct mbuf { #define CSUM_IP_SCTP 0x00000008 /* SCTP checksum offload */ #define CSUM_IP_TSO 0x00000010 /* TCP segmentation offload */ #define CSUM_IP_ISCSI 0x00000020 /* iSCSI checksum offload */ +#define CSUM_IP_UDP_TRAIL 0x00000040 /* UDP trailing data */ #define CSUM_IP6_UDP 0x00000200 /* UDP checksum offload */ #define CSUM_IP6_TCP 0x00000400 /* TCP checksum offload */ @@ -524,7 +525,7 @@ struct mbuf { */ #define CSUM_BITS \ "\20\1CSUM_IP\2CSUM_IP_UDP\3CSUM_IP_TCP\4CSUM_IP_SCTP\5CSUM_IP_TSO" \ - "\6CSUM_IP_ISCSI" \ + "\6CSUM_IP_ISCSI\7CSUM_IP_UDP_TRAIL" \ "\12CSUM_IP6_UDP\13CSUM_IP6_TCP\14CSUM_IP6_SCTP\15CSUM_IP6_TSO" \ "\16CSUM_IP6_ISCSI" \ "\31CSUM_L3_CALC\32CSUM_L3_VALID\33CSUM_L4_CALC\34CSUM_L4_VALID" \ @@ -542,6 +543,7 @@ struct mbuf { #define CSUM_DATA_VALID_IPV6 CSUM_DATA_VALID #define CSUM_TCP CSUM_IP_TCP #define CSUM_UDP CSUM_IP_UDP +#define CSUM_UDP_TRAIL CSUM_IP_UDP_TRAIL #define CSUM_SCTP CSUM_IP_SCTP #define CSUM_TSO (CSUM_IP_TSO|CSUM_IP6_TSO) #define CSUM_UDP_IPV6 CSUM_IP6_UDP