]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - net/ipv4/ip_input.c
udp: only do GSO if # of segs > 1
[linux.git] / net / ipv4 / ip_input.c
index 1132d6d1796a4f7c947da76b9b39e7fbe11d3399..c59a78a267c37ab3a434c38c0ab236f2f5f2a0f1 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * INET                An implementation of the TCP/IP protocol suite for the LINUX
  *             operating system.  INET is implemented using the  BSD Socket
@@ -14,7 +15,6 @@
  *             Jorge Cwik, <jorge@laser.satlink.net>
  *             Arnt Gulbrandsen, <agulbra@nvg.unit.no>
  *
- *
  * Fixes:
  *             Alan Cox        :       Commented a couple of minor bits of surplus code
  *             Alan Cox        :       Undefining IP_FORWARD doesn't include the code
@@ -96,8 +96,6 @@
  *             Jos Vos         :       Do accounting *before* call_in_firewall
  *     Willy Konynenberg       :       Transparent proxying support
  *
- *
- *
  * To Fix:
  *             IP fragmentation wants rewriting cleanly. The RFC815 algorithm is much more efficient
  *             and could be made very efficient with the addition of some virtual memory hacks to permit
  *             interleaved copy algorithm so that fragmenting has a one copy overhead. Actual packet
  *             output should probably do its own fragmentation at the UDP/RAW layer. TCP shouldn't cause
  *             fragmentation anyway.
- *
- *             This program is free software; you can redistribute it and/or
- *             modify it under the terms of the GNU General Public License
- *             as published by the Free Software Foundation; either version
- *             2 of the License, or (at your option) any later version.
  */
 
 #define pr_fmt(fmt) "IPv4: " fmt
 #include <linux/inetdevice.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
+#include <linux/indirect_call_wrapper.h>
 
 #include <net/snmp.h>
 #include <net/ip.h>
@@ -188,6 +182,8 @@ bool ip_call_ra_chain(struct sk_buff *skb)
        return false;
 }
 
+INDIRECT_CALLABLE_DECLARE(int udp_rcv(struct sk_buff *));
+INDIRECT_CALLABLE_DECLARE(int tcp_v4_rcv(struct sk_buff *));
 void ip_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int protocol)
 {
        const struct net_protocol *ipprot;
@@ -203,9 +199,10 @@ void ip_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int protocol)
                                kfree_skb(skb);
                                return;
                        }
-                       nf_reset(skb);
+                       nf_reset_ct(skb);
                }
-               ret = ipprot->handler(skb);
+               ret = INDIRECT_CALL_2(ipprot->handler, tcp_v4_rcv, udp_rcv,
+                                     skb);
                if (ret < 0) {
                        protocol = -ret;
                        goto resubmit;
@@ -305,6 +302,8 @@ static inline bool ip_rcv_options(struct sk_buff *skb, struct net_device *dev)
        return true;
 }
 
+INDIRECT_CALLABLE_DECLARE(int udp_v4_early_demux(struct sk_buff *));
+INDIRECT_CALLABLE_DECLARE(int tcp_v4_early_demux(struct sk_buff *));
 static int ip_rcv_finish_core(struct net *net, struct sock *sk,
                              struct sk_buff *skb, struct net_device *dev)
 {
@@ -322,7 +321,8 @@ static int ip_rcv_finish_core(struct net *net, struct sock *sk,
 
                ipprot = rcu_dereference(inet_protos[protocol]);
                if (ipprot && (edemux = READ_ONCE(ipprot->early_demux))) {
-                       err = edemux(skb);
+                       err = INDIRECT_CALL_2(edemux, tcp_v4_early_demux,
+                                             udp_v4_early_demux, skb);
                        if (unlikely(err))
                                goto drop_error;
                        /* must reload iph, skb->head might have changed */