--- zzzz-none-000/linux-4.9.279/net/ipv4/udp.c 2021-08-08 06:38:54.000000000 +0000 +++ puma7-atom-6591-750/linux-4.9.279/net/ipv4/udp.c 2023-02-08 11:43:43.000000000 +0000 @@ -76,6 +76,10 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ +/* + Includes Intel Corporation's changes/modifications dated: 2018 + Changed/modified portions - Copyright (C) 2018, Intel Corporation. +*/ #define pr_fmt(fmt) "UDP: " fmt @@ -116,6 +120,8 @@ #include #include +#include + struct udp_table udp_table __read_mostly; EXPORT_SYMBOL(udp_table); @@ -131,6 +137,9 @@ atomic_long_t udp_memory_allocated; EXPORT_SYMBOL(udp_memory_allocated); +bool toe_udp_early_demux_no_scan_limit = false; +EXPORT_SYMBOL(toe_udp_early_demux_no_scan_limit); + #define MAX_UDP_PORTS 65536 #define PORTS_PER_CHAIN (MAX_UDP_PORTS / UDP_HTABLE_SIZE_MIN) @@ -559,11 +568,13 @@ __be16 sport, __be16 dport, struct udp_table *udptable) { + struct sock *sk; const struct iphdr *iph = ip_hdr(skb); - return __udp4_lib_lookup(dev_net(skb->dev), iph->saddr, sport, + sk = __udp4_lib_lookup(dev_net(skb->dev), iph->saddr, sport, iph->daddr, dport, inet_iif(skb), udptable, skb); + return sk; } struct sock *udp4_lib_lookup_skb(struct sk_buff *skb, @@ -955,6 +966,9 @@ ipc.sockc.tsflags = sk->sk_tsflags; ipc.addr = inet->inet_saddr; +#ifdef CONFIG_TI_META_DATA + ipc.ti_meta_info = 0; +#endif ipc.oif = sk->sk_bound_dev_if; if (msg->msg_controllen) { @@ -1022,7 +1036,8 @@ flowi4_init_output(fl4, ipc.oif, sk->sk_mark, tos, RT_SCOPE_UNIVERSE, sk->sk_protocol, flow_flags, - faddr, saddr, dport, inet->inet_sport); + faddr, saddr, dport, inet->inet_sport, + sk->sk_uid); security_sk_classify_flow(sk, flowi4_to_flowi(fl4)); rt = ip_route_output_flow(net, fl4, sk); @@ -1506,6 +1521,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) { struct udp_sock *up = udp_sk(sk); + struct net *net = dev_net(skb->dev); int rc; int is_udplite = IS_UDPLITE(sk); @@ -1514,6 +1530,9 @@ */ if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) goto drop; + + avm_pa_add_local_session(AVM_PA_NET_IP_DEVINFO(net), skb, sk); + nf_reset(skb); if (static_key_false(&udp_encap_needed) && up->encap_type) { @@ -1625,7 +1644,7 @@ /* For TCP sockets, sk_rx_dst is protected by socket lock * For UDP, we use xchg() to guard against concurrent changes. */ -static void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst) +void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst) { struct dst_entry *old; @@ -1670,6 +1689,7 @@ if (!first) { first = sk; + continue; } nskb = skb_clone(skb, GFP_ATOMIC); @@ -1919,13 +1939,15 @@ INET_ADDR_COOKIE(acookie, rmt_addr, loc_addr); const __portpair ports = INET_COMBINED_PORTS(rmt_port, hnum); struct sock *sk; + bool scan_limit = !toe_udp_early_demux_no_scan_limit; udp_portaddr_for_each_entry_rcu(sk, &hslot2->head) { if (INET_MATCH(sk, net, acookie, rmt_addr, loc_addr, ports, dif)) return sk; - /* Only check first socket in chain */ - break; + if (scan_limit) + /* Only check first socket in chain */ + break; } return NULL; } @@ -2010,6 +2032,7 @@ encap_destroy(sk); } } +EXPORT_SYMBOL(udp_sk_rx_dst_set); /* * Socket option code for UDP