hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/udp.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * INET An implementation of the TCP/IP protocol suite for the LINUX
34 * operating system. INET is implemented using the BSD Socket
....@@ -8,11 +9,6 @@
89 * Version: @(#)udp.h 1.0.2 04/28/93
910 *
1011 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
11
- *
12
- * This program is free software; you can redistribute it and/or
13
- * modify it under the terms of the GNU General Public License
14
- * as published by the Free Software Foundation; either version
15
- * 2 of the License, or (at your option) any later version.
1612 */
1713 #ifndef _LINUX_UDP_H
1814 #define _LINUX_UDP_H
....@@ -49,7 +45,15 @@
4945 unsigned int corkflag; /* Cork is required */
5046 __u8 encap_type; /* Is this an Encapsulation socket? */
5147 unsigned char no_check6_tx:1,/* Send zero UDP6 checksums on TX? */
52
- no_check6_rx:1;/* Allow zero UDP6 checksums on RX? */
48
+ no_check6_rx:1,/* Allow zero UDP6 checksums on RX? */
49
+ encap_enabled:1, /* This socket enabled encap
50
+ * processing; UDP tunnels and
51
+ * different encapsulation layer set
52
+ * this
53
+ */
54
+ gro_enabled:1, /* Request GRO aggregation */
55
+ accept_udp_l4:1,
56
+ accept_udp_fraglist:1;
5357 /*
5458 * Following member retains the information to create a UDP header
5559 * when the socket is uncorked.
....@@ -71,6 +75,7 @@
7175 * For encapsulation sockets.
7276 */
7377 int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);
78
+ int (*encap_err_lookup)(struct sock *sk, struct sk_buff *skb);
7479 void (*encap_destroy)(struct sock *sk);
7580
7681 /* GRO functions for UDP socket */
....@@ -115,6 +120,31 @@
115120 return udp_sk(sk)->no_check6_rx;
116121 }
117122
123
+static inline void udp_cmsg_recv(struct msghdr *msg, struct sock *sk,
124
+ struct sk_buff *skb)
125
+{
126
+ int gso_size;
127
+
128
+ if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) {
129
+ gso_size = skb_shinfo(skb)->gso_size;
130
+ put_cmsg(msg, SOL_UDP, UDP_GRO, sizeof(gso_size), &gso_size);
131
+ }
132
+}
133
+
134
+static inline bool udp_unexpected_gso(struct sock *sk, struct sk_buff *skb)
135
+{
136
+ if (!skb_is_gso(skb))
137
+ return false;
138
+
139
+ if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4 && !udp_sk(sk)->accept_udp_l4)
140
+ return true;
141
+
142
+ if (skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST && !udp_sk(sk)->accept_udp_fraglist)
143
+ return true;
144
+
145
+ return false;
146
+}
147
+
118148 #define udp_portaddr_for_each_entry(__sk, list) \
119149 hlist_for_each_entry(__sk, list, __sk_common.skc_portaddr_node)
120150