summaryrefslogtreecommitdiffstats
path: root/sys/netinet/udp_usrreq.c
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2011-04-14 10:40:57 +0000
committertrasz <trasz@FreeBSD.org>2011-04-14 10:40:57 +0000
commit77372012bcb9187ca9de64048c62661460cf0614 (patch)
treea2ef572c7abeabef56bf6f9a6e324e3f4db2095f /sys/netinet/udp_usrreq.c
parentc3c7ca25e7e6cc299b2e774daa2512d0f731702c (diff)
downloadFreeBSD-src-77372012bcb9187ca9de64048c62661460cf0614.zip
FreeBSD-src-77372012bcb9187ca9de64048c62661460cf0614.tar.gz
Refactor udp_input(), moving calls to u_tun_func() into udp_append().
Obtained from: Wheel Systems Sp. z o.o. Reviewed by: bz@
Diffstat (limited to 'sys/netinet/udp_usrreq.c')
-rw-r--r--sys/netinet/udp_usrreq.c62
1 files changed, 17 insertions, 45 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 589585c..e9252dc 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -246,16 +246,24 @@ udp_append(struct inpcb *inp, struct ip *ip, struct mbuf *n, int off,
#ifdef INET6
struct sockaddr_in6 udp_in6;
#endif
-#ifdef IPSEC
-#ifdef IPSEC_NAT_T
-#ifdef INET
struct udpcb *up;
-#endif
-#endif
-#endif
INP_RLOCK_ASSERT(inp);
+ /*
+ * Engage the tunneling protocol.
+ */
+ up = intoudpcb(inp);
+ if (up->u_tun_func != NULL) {
+ (*up->u_tun_func)(n, off, inp);
+ return;
+ }
+
+ if (n == NULL)
+ return;
+
+ off += sizeof(struct udphdr);
+
#ifdef IPSEC
/* Check AH/ESP integrity. */
if (ipsec4_in_reject(n, inp)) {
@@ -322,7 +330,6 @@ udp_input(struct mbuf *m, int off)
struct udphdr *uh;
struct ifnet *ifp;
struct inpcb *inp;
- struct udpcb *up;
int len;
struct ip save_ip;
struct sockaddr_in udp_in;
@@ -508,24 +515,7 @@ udp_input(struct mbuf *m, int off)
struct mbuf *n;
n = m_copy(m, 0, M_COPYALL);
- up = intoudpcb(last);
- if (up->u_tun_func == NULL) {
- if (n != NULL)
- udp_append(last,
- ip, n,
- iphlen +
- sizeof(struct udphdr),
- &udp_in);
- } else {
- /*
- * Engage the tunneling protocol we
- * will have to leave the info_lock
- * up, since we are hunting through
- * multiple UDP's.
- */
-
- (*up->u_tun_func)(n, iphlen, last);
- }
+ udp_append(last, ip, n, iphlen, &udp_in);
INP_RUNLOCK(last);
}
last = inp;
@@ -551,16 +541,7 @@ udp_input(struct mbuf *m, int off)
UDPSTAT_INC(udps_noportbcast);
goto badheadlocked;
}
- up = intoudpcb(last);
- if (up->u_tun_func == NULL) {
- udp_append(last, ip, m, iphlen + sizeof(struct udphdr),
- &udp_in);
- } else {
- /*
- * Engage the tunneling protocol.
- */
- (*up->u_tun_func)(m, iphlen, last);
- }
+ udp_append(last, ip, m, iphlen, &udp_in);
INP_RUNLOCK(last);
INP_INFO_RUNLOCK(&V_udbinfo);
return;
@@ -606,16 +587,7 @@ udp_input(struct mbuf *m, int off)
INP_RUNLOCK(inp);
goto badunlocked;
}
- up = intoudpcb(inp);
- if (up->u_tun_func == NULL) {
- udp_append(inp, ip, m, iphlen + sizeof(struct udphdr), &udp_in);
- } else {
- /*
- * Engage the tunneling protocol.
- */
-
- (*up->u_tun_func)(m, iphlen, inp);
- }
+ udp_append(inp, ip, m, iphlen, &udp_in);
INP_RUNLOCK(inp);
return;
OpenPOWER on IntegriCloud