diff options
Diffstat (limited to 'include/net')
56 files changed, 839 insertions, 208 deletions
diff --git a/include/net/addrconf.h b/include/net/addrconf.h index cbc6bb0a6838..f68dce2d8d88 100644 --- a/include/net/addrconf.h +++ b/include/net/addrconf.h | |||
@@ -151,7 +151,8 @@ extern int ipv6_chk_mcast_addr(struct net_device *dev, | |||
151 | const struct in6_addr *src_addr); | 151 | const struct in6_addr *src_addr); |
152 | extern int ipv6_is_mld(struct sk_buff *skb, int nexthdr); | 152 | extern int ipv6_is_mld(struct sk_buff *skb, int nexthdr); |
153 | 153 | ||
154 | extern void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len); | 154 | extern void addrconf_prefix_rcv(struct net_device *dev, |
155 | u8 *opt, int len, bool sllao); | ||
155 | 156 | ||
156 | /* | 157 | /* |
157 | * anycast prototypes (anycast.c) | 158 | * anycast prototypes (anycast.c) |
diff --git a/include/net/af_unix.h b/include/net/af_unix.h index 91ab5b01678a..5a4e29b168c9 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h | |||
@@ -11,10 +11,13 @@ extern void unix_notinflight(struct file *fp); | |||
11 | extern void unix_gc(void); | 11 | extern void unix_gc(void); |
12 | extern void wait_for_unix_gc(void); | 12 | extern void wait_for_unix_gc(void); |
13 | extern struct sock *unix_get_socket(struct file *filp); | 13 | extern struct sock *unix_get_socket(struct file *filp); |
14 | extern struct sock *unix_peer_get(struct sock *); | ||
14 | 15 | ||
15 | #define UNIX_HASH_SIZE 256 | 16 | #define UNIX_HASH_SIZE 256 |
16 | 17 | ||
17 | extern unsigned int unix_tot_inflight; | 18 | extern unsigned int unix_tot_inflight; |
19 | extern spinlock_t unix_table_lock; | ||
20 | extern struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1]; | ||
18 | 21 | ||
19 | struct unix_address { | 22 | struct unix_address { |
20 | atomic_t refcnt; | 23 | atomic_t refcnt; |
@@ -63,6 +66,9 @@ struct unix_sock { | |||
63 | 66 | ||
64 | #define peer_wait peer_wq.wait | 67 | #define peer_wait peer_wq.wait |
65 | 68 | ||
69 | long unix_inq_len(struct sock *sk); | ||
70 | long unix_outq_len(struct sock *sk); | ||
71 | |||
66 | #ifdef CONFIG_SYSCTL | 72 | #ifdef CONFIG_SYSCTL |
67 | extern int unix_sysctl_register(struct net *net); | 73 | extern int unix_sysctl_register(struct net *net); |
68 | extern void unix_sysctl_unregister(struct net *net); | 74 | extern void unix_sysctl_unregister(struct net *net); |
diff --git a/include/net/arp.h b/include/net/arp.h index 4979af8b1559..0013dc87940b 100644 --- a/include/net/arp.h +++ b/include/net/arp.h | |||
@@ -23,7 +23,7 @@ static inline struct neighbour *__ipv4_neigh_lookup(struct neigh_table *tbl, str | |||
23 | 23 | ||
24 | rcu_read_lock_bh(); | 24 | rcu_read_lock_bh(); |
25 | nht = rcu_dereference_bh(tbl->nht); | 25 | nht = rcu_dereference_bh(tbl->nht); |
26 | hash_val = arp_hashfn(key, dev, nht->hash_rnd) >> (32 - nht->hash_shift); | 26 | hash_val = arp_hashfn(key, dev, nht->hash_rnd[0]) >> (32 - nht->hash_shift); |
27 | for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]); | 27 | for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]); |
28 | n != NULL; | 28 | n != NULL; |
29 | n = rcu_dereference_bh(n->next)) { | 29 | n = rcu_dereference_bh(n->next)) { |
diff --git a/include/net/atmclip.h b/include/net/atmclip.h index 497ef6444a7a..5865924d4aac 100644 --- a/include/net/atmclip.h +++ b/include/net/atmclip.h | |||
@@ -15,7 +15,6 @@ | |||
15 | 15 | ||
16 | 16 | ||
17 | #define CLIP_VCC(vcc) ((struct clip_vcc *) ((vcc)->user_back)) | 17 | #define CLIP_VCC(vcc) ((struct clip_vcc *) ((vcc)->user_back)) |
18 | #define NEIGH2ENTRY(neigh) ((struct atmarp_entry *) (neigh)->primary_key) | ||
19 | 18 | ||
20 | struct sk_buff; | 19 | struct sk_buff; |
21 | 20 | ||
@@ -36,24 +35,18 @@ struct clip_vcc { | |||
36 | 35 | ||
37 | 36 | ||
38 | struct atmarp_entry { | 37 | struct atmarp_entry { |
39 | __be32 ip; /* IP address */ | ||
40 | struct clip_vcc *vccs; /* active VCCs; NULL if resolution is | 38 | struct clip_vcc *vccs; /* active VCCs; NULL if resolution is |
41 | pending */ | 39 | pending */ |
42 | unsigned long expires; /* entry expiration time */ | 40 | unsigned long expires; /* entry expiration time */ |
43 | struct neighbour *neigh; /* neighbour back-pointer */ | 41 | struct neighbour *neigh; /* neighbour back-pointer */ |
44 | }; | 42 | }; |
45 | 43 | ||
46 | |||
47 | #define PRIV(dev) ((struct clip_priv *) netdev_priv(dev)) | 44 | #define PRIV(dev) ((struct clip_priv *) netdev_priv(dev)) |
48 | 45 | ||
49 | |||
50 | struct clip_priv { | 46 | struct clip_priv { |
51 | int number; /* for convenience ... */ | 47 | int number; /* for convenience ... */ |
52 | spinlock_t xoff_lock; /* ensures that pop is atomic (SMP) */ | 48 | spinlock_t xoff_lock; /* ensures that pop is atomic (SMP) */ |
53 | struct net_device *next; /* next CLIP interface */ | 49 | struct net_device *next; /* next CLIP interface */ |
54 | }; | 50 | }; |
55 | 51 | ||
56 | |||
57 | extern struct neigh_table *clip_tbl_hook; | ||
58 | |||
59 | #endif | 52 | #endif |
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 9572cbd12a7a..68f589150692 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -820,7 +820,7 @@ static inline __u8 __ctrl_size(struct l2cap_chan *chan) | |||
820 | return L2CAP_ENH_HDR_SIZE - L2CAP_HDR_SIZE; | 820 | return L2CAP_ENH_HDR_SIZE - L2CAP_HDR_SIZE; |
821 | } | 821 | } |
822 | 822 | ||
823 | extern int disable_ertm; | 823 | extern bool disable_ertm; |
824 | 824 | ||
825 | int l2cap_init_sockets(void); | 825 | int l2cap_init_sockets(void); |
826 | void l2cap_cleanup_sockets(void); | 826 | void l2cap_cleanup_sockets(void); |
diff --git a/include/net/caif/caif_dev.h b/include/net/caif/caif_dev.h index c011281d92c0..ef2dd9438bb1 100644 --- a/include/net/caif/caif_dev.h +++ b/include/net/caif/caif_dev.h | |||
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | #include <net/caif/caif_layer.h> | 10 | #include <net/caif/caif_layer.h> |
11 | #include <net/caif/cfcnfg.h> | 11 | #include <net/caif/cfcnfg.h> |
12 | #include <net/caif/caif_device.h> | ||
12 | #include <linux/caif/caif_socket.h> | 13 | #include <linux/caif/caif_socket.h> |
13 | #include <linux/if.h> | 14 | #include <linux/if.h> |
14 | #include <linux/net.h> | 15 | #include <linux/net.h> |
@@ -104,4 +105,24 @@ void caif_client_register_refcnt(struct cflayer *adapt_layer, | |||
104 | */ | 105 | */ |
105 | void caif_free_client(struct cflayer *adap_layer); | 106 | void caif_free_client(struct cflayer *adap_layer); |
106 | 107 | ||
108 | /** | ||
109 | * struct caif_enroll_dev - Enroll a net-device as a CAIF Link layer | ||
110 | * @dev: Network device to enroll. | ||
111 | * @caifdev: Configuration information from CAIF Link Layer | ||
112 | * @link_support: Link layer support layer | ||
113 | * @head_room: Head room needed by link support layer | ||
114 | * @layer: Lowest layer in CAIF stack | ||
115 | * @rcv_fun: Receive function for CAIF stack. | ||
116 | * | ||
117 | * This function enroll a CAIF link layer into CAIF Stack and | ||
118 | * expects the interface to be able to handle CAIF payload. | ||
119 | * The link_support layer is used to add any Link Layer specific | ||
120 | * framing. | ||
121 | */ | ||
122 | void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev, | ||
123 | struct cflayer *link_support, int head_room, | ||
124 | struct cflayer **layer, int (**rcv_func)( | ||
125 | struct sk_buff *, struct net_device *, | ||
126 | struct packet_type *, struct net_device *)); | ||
127 | |||
107 | #endif /* CAIF_DEV_H_ */ | 128 | #endif /* CAIF_DEV_H_ */ |
diff --git a/include/net/caif/caif_layer.h b/include/net/caif/caif_layer.h index 35bc7883cf97..0f3a39125f90 100644 --- a/include/net/caif/caif_layer.h +++ b/include/net/caif/caif_layer.h | |||
@@ -121,9 +121,7 @@ enum caif_direction { | |||
121 | * @transmit: Packet transmit funciton. | 121 | * @transmit: Packet transmit funciton. |
122 | * @ctrlcmd: Used for control signalling upwards in the stack. | 122 | * @ctrlcmd: Used for control signalling upwards in the stack. |
123 | * @modemcmd: Used for control signaling downwards in the stack. | 123 | * @modemcmd: Used for control signaling downwards in the stack. |
124 | * @prio: Priority of this layer. | ||
125 | * @id: The identity of this layer | 124 | * @id: The identity of this layer |
126 | * @type: The type of this layer | ||
127 | * @name: Name of the layer. | 125 | * @name: Name of the layer. |
128 | * | 126 | * |
129 | * This structure defines the layered structure in CAIF. | 127 | * This structure defines the layered structure in CAIF. |
@@ -230,9 +228,7 @@ struct cflayer { | |||
230 | */ | 228 | */ |
231 | int (*modemcmd) (struct cflayer *layr, enum caif_modemcmd ctrl); | 229 | int (*modemcmd) (struct cflayer *layr, enum caif_modemcmd ctrl); |
232 | 230 | ||
233 | unsigned short prio; | ||
234 | unsigned int id; | 231 | unsigned int id; |
235 | unsigned int type; | ||
236 | char name[CAIF_LAYER_NAME_SZ]; | 232 | char name[CAIF_LAYER_NAME_SZ]; |
237 | }; | 233 | }; |
238 | 234 | ||
diff --git a/include/net/caif/caif_spi.h b/include/net/caif/caif_spi.h index 87c3d11b8e55..aa6a485b0545 100644 --- a/include/net/caif/caif_spi.h +++ b/include/net/caif/caif_spi.h | |||
@@ -55,8 +55,8 @@ | |||
55 | struct cfspi_xfer { | 55 | struct cfspi_xfer { |
56 | u16 tx_dma_len; | 56 | u16 tx_dma_len; |
57 | u16 rx_dma_len; | 57 | u16 rx_dma_len; |
58 | void *va_tx; | 58 | void *va_tx[2]; |
59 | dma_addr_t pa_tx; | 59 | dma_addr_t pa_tx[2]; |
60 | void *va_rx; | 60 | void *va_rx; |
61 | dma_addr_t pa_rx; | 61 | dma_addr_t pa_rx; |
62 | }; | 62 | }; |
diff --git a/include/net/caif/cfcnfg.h b/include/net/caif/cfcnfg.h index 3e93a4a4b677..90b4ff8bad83 100644 --- a/include/net/caif/cfcnfg.h +++ b/include/net/caif/cfcnfg.h | |||
@@ -14,18 +14,6 @@ | |||
14 | struct cfcnfg; | 14 | struct cfcnfg; |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * enum cfcnfg_phy_type - Types of physical layers defined in CAIF Stack | ||
18 | * | ||
19 | * @CFPHYTYPE_FRAG: Fragmented frames physical interface. | ||
20 | * @CFPHYTYPE_CAIF: Generic CAIF physical interface | ||
21 | */ | ||
22 | enum cfcnfg_phy_type { | ||
23 | CFPHYTYPE_FRAG = 1, | ||
24 | CFPHYTYPE_CAIF, | ||
25 | CFPHYTYPE_MAX | ||
26 | }; | ||
27 | |||
28 | /** | ||
29 | * enum cfcnfg_phy_preference - Physical preference HW Abstraction | 17 | * enum cfcnfg_phy_preference - Physical preference HW Abstraction |
30 | * | 18 | * |
31 | * @CFPHYPREF_UNSPECIFIED: Default physical interface | 19 | * @CFPHYPREF_UNSPECIFIED: Default physical interface |
@@ -66,21 +54,20 @@ void cfcnfg_remove(struct cfcnfg *cfg); | |||
66 | * cfcnfg_add_phy_layer() - Adds a physical layer to the CAIF stack. | 54 | * cfcnfg_add_phy_layer() - Adds a physical layer to the CAIF stack. |
67 | * @cnfg: Pointer to a CAIF configuration object, created by | 55 | * @cnfg: Pointer to a CAIF configuration object, created by |
68 | * cfcnfg_create(). | 56 | * cfcnfg_create(). |
69 | * @phy_type: Specifies the type of physical interface, e.g. | ||
70 | * CFPHYTYPE_FRAG. | ||
71 | * @dev: Pointer to link layer device | 57 | * @dev: Pointer to link layer device |
72 | * @phy_layer: Specify the physical layer. The transmit function | 58 | * @phy_layer: Specify the physical layer. The transmit function |
73 | * MUST be set in the structure. | 59 | * MUST be set in the structure. |
74 | * @pref: The phy (link layer) preference. | 60 | * @pref: The phy (link layer) preference. |
61 | * @link_support: Protocol implementation for link layer specific protocol. | ||
75 | * @fcs: Specify if checksum is used in CAIF Framing Layer. | 62 | * @fcs: Specify if checksum is used in CAIF Framing Layer. |
76 | * @stx: Specify if Start Of Frame eXtention is used. | 63 | * @head_room: Head space needed by link specific protocol. |
77 | */ | 64 | */ |
78 | |||
79 | void | 65 | void |
80 | cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, | 66 | cfcnfg_add_phy_layer(struct cfcnfg *cnfg, |
81 | struct net_device *dev, struct cflayer *phy_layer, | 67 | struct net_device *dev, struct cflayer *phy_layer, |
82 | enum cfcnfg_phy_preference pref, | 68 | enum cfcnfg_phy_preference pref, |
83 | bool fcs, bool stx); | 69 | struct cflayer *link_support, |
70 | bool fcs, int head_room); | ||
84 | 71 | ||
85 | /** | 72 | /** |
86 | * cfcnfg_del_phy_layer - Deletes an phy layer from the CAIF stack. | 73 | * cfcnfg_del_phy_layer - Deletes an phy layer from the CAIF stack. |
diff --git a/include/net/caif/cfserl.h b/include/net/caif/cfserl.h index b8374321b362..f121299a3427 100644 --- a/include/net/caif/cfserl.h +++ b/include/net/caif/cfserl.h | |||
@@ -8,5 +8,5 @@ | |||
8 | #define CFSERL_H_ | 8 | #define CFSERL_H_ |
9 | #include <net/caif/caif_layer.h> | 9 | #include <net/caif/caif_layer.h> |
10 | 10 | ||
11 | struct cflayer *cfserl_create(int type, int instance, bool use_stx); | 11 | struct cflayer *cfserl_create(int instance, bool use_stx); |
12 | #endif /* CFSERL_H_ */ | 12 | #endif |
diff --git a/include/net/dsa.h b/include/net/dsa.h index 839f768f9e35..7828ebf99ee1 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h | |||
@@ -11,6 +11,11 @@ | |||
11 | #ifndef __LINUX_NET_DSA_H | 11 | #ifndef __LINUX_NET_DSA_H |
12 | #define __LINUX_NET_DSA_H | 12 | #define __LINUX_NET_DSA_H |
13 | 13 | ||
14 | #include <linux/if_ether.h> | ||
15 | #include <linux/list.h> | ||
16 | #include <linux/timer.h> | ||
17 | #include <linux/workqueue.h> | ||
18 | |||
14 | #define DSA_MAX_SWITCHES 4 | 19 | #define DSA_MAX_SWITCHES 4 |
15 | #define DSA_MAX_PORTS 12 | 20 | #define DSA_MAX_PORTS 12 |
16 | 21 | ||
@@ -54,8 +59,143 @@ struct dsa_platform_data { | |||
54 | struct dsa_chip_data *chip; | 59 | struct dsa_chip_data *chip; |
55 | }; | 60 | }; |
56 | 61 | ||
57 | extern bool dsa_uses_dsa_tags(void *dsa_ptr); | 62 | struct dsa_switch_tree { |
58 | extern bool dsa_uses_trailer_tags(void *dsa_ptr); | 63 | /* |
64 | * Configuration data for the platform device that owns | ||
65 | * this dsa switch tree instance. | ||
66 | */ | ||
67 | struct dsa_platform_data *pd; | ||
68 | |||
69 | /* | ||
70 | * Reference to network device to use, and which tagging | ||
71 | * protocol to use. | ||
72 | */ | ||
73 | struct net_device *master_netdev; | ||
74 | __be16 tag_protocol; | ||
75 | |||
76 | /* | ||
77 | * The switch and port to which the CPU is attached. | ||
78 | */ | ||
79 | s8 cpu_switch; | ||
80 | s8 cpu_port; | ||
81 | |||
82 | /* | ||
83 | * Link state polling. | ||
84 | */ | ||
85 | int link_poll_needed; | ||
86 | struct work_struct link_poll_work; | ||
87 | struct timer_list link_poll_timer; | ||
88 | |||
89 | /* | ||
90 | * Data for the individual switch chips. | ||
91 | */ | ||
92 | struct dsa_switch *ds[DSA_MAX_SWITCHES]; | ||
93 | }; | ||
94 | |||
95 | struct dsa_switch { | ||
96 | /* | ||
97 | * Parent switch tree, and switch index. | ||
98 | */ | ||
99 | struct dsa_switch_tree *dst; | ||
100 | int index; | ||
101 | |||
102 | /* | ||
103 | * Configuration data for this switch. | ||
104 | */ | ||
105 | struct dsa_chip_data *pd; | ||
106 | |||
107 | /* | ||
108 | * The used switch driver. | ||
109 | */ | ||
110 | struct dsa_switch_driver *drv; | ||
111 | |||
112 | /* | ||
113 | * Reference to mii bus to use. | ||
114 | */ | ||
115 | struct mii_bus *master_mii_bus; | ||
116 | |||
117 | /* | ||
118 | * Slave mii_bus and devices for the individual ports. | ||
119 | */ | ||
120 | u32 dsa_port_mask; | ||
121 | u32 phys_port_mask; | ||
122 | struct mii_bus *slave_mii_bus; | ||
123 | struct net_device *ports[DSA_MAX_PORTS]; | ||
124 | }; | ||
125 | |||
126 | static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p) | ||
127 | { | ||
128 | return !!(ds->index == ds->dst->cpu_switch && p == ds->dst->cpu_port); | ||
129 | } | ||
130 | |||
131 | static inline u8 dsa_upstream_port(struct dsa_switch *ds) | ||
132 | { | ||
133 | struct dsa_switch_tree *dst = ds->dst; | ||
134 | |||
135 | /* | ||
136 | * If this is the root switch (i.e. the switch that connects | ||
137 | * to the CPU), return the cpu port number on this switch. | ||
138 | * Else return the (DSA) port number that connects to the | ||
139 | * switch that is one hop closer to the cpu. | ||
140 | */ | ||
141 | if (dst->cpu_switch == ds->index) | ||
142 | return dst->cpu_port; | ||
143 | else | ||
144 | return ds->pd->rtable[dst->cpu_switch]; | ||
145 | } | ||
146 | |||
147 | struct dsa_switch_driver { | ||
148 | struct list_head list; | ||
149 | |||
150 | __be16 tag_protocol; | ||
151 | int priv_size; | ||
152 | |||
153 | /* | ||
154 | * Probing and setup. | ||
155 | */ | ||
156 | char *(*probe)(struct mii_bus *bus, int sw_addr); | ||
157 | int (*setup)(struct dsa_switch *ds); | ||
158 | int (*set_addr)(struct dsa_switch *ds, u8 *addr); | ||
159 | |||
160 | /* | ||
161 | * Access to the switch's PHY registers. | ||
162 | */ | ||
163 | int (*phy_read)(struct dsa_switch *ds, int port, int regnum); | ||
164 | int (*phy_write)(struct dsa_switch *ds, int port, | ||
165 | int regnum, u16 val); | ||
166 | |||
167 | /* | ||
168 | * Link state polling and IRQ handling. | ||
169 | */ | ||
170 | void (*poll_link)(struct dsa_switch *ds); | ||
171 | |||
172 | /* | ||
173 | * ethtool hardware statistics. | ||
174 | */ | ||
175 | void (*get_strings)(struct dsa_switch *ds, int port, uint8_t *data); | ||
176 | void (*get_ethtool_stats)(struct dsa_switch *ds, | ||
177 | int port, uint64_t *data); | ||
178 | int (*get_sset_count)(struct dsa_switch *ds); | ||
179 | }; | ||
180 | |||
181 | void register_switch_driver(struct dsa_switch_driver *type); | ||
182 | void unregister_switch_driver(struct dsa_switch_driver *type); | ||
183 | |||
184 | /* | ||
185 | * The original DSA tag format and some other tag formats have no | ||
186 | * ethertype, which means that we need to add a little hack to the | ||
187 | * networking receive path to make sure that received frames get | ||
188 | * the right ->protocol assigned to them when one of those tag | ||
189 | * formats is in use. | ||
190 | */ | ||
191 | static inline bool dsa_uses_dsa_tags(struct dsa_switch_tree *dst) | ||
192 | { | ||
193 | return !!(dst->tag_protocol == htons(ETH_P_DSA)); | ||
194 | } | ||
59 | 195 | ||
196 | static inline bool dsa_uses_trailer_tags(struct dsa_switch_tree *dst) | ||
197 | { | ||
198 | return !!(dst->tag_protocol == htons(ETH_P_TRAILER)); | ||
199 | } | ||
60 | 200 | ||
61 | #endif | 201 | #endif |
diff --git a/include/net/dst.h b/include/net/dst.h index 4fb6c4381791..344c8dd02874 100644 --- a/include/net/dst.h +++ b/include/net/dst.h | |||
@@ -53,6 +53,7 @@ struct dst_entry { | |||
53 | #define DST_NOHASH 0x0008 | 53 | #define DST_NOHASH 0x0008 |
54 | #define DST_NOCACHE 0x0010 | 54 | #define DST_NOCACHE 0x0010 |
55 | #define DST_NOCOUNT 0x0020 | 55 | #define DST_NOCOUNT 0x0020 |
56 | #define DST_NOPEER 0x0040 | ||
56 | 57 | ||
57 | short error; | 58 | short error; |
58 | short obsolete; | 59 | short obsolete; |
@@ -86,12 +87,12 @@ struct dst_entry { | |||
86 | }; | 87 | }; |
87 | }; | 88 | }; |
88 | 89 | ||
89 | static inline struct neighbour *dst_get_neighbour(struct dst_entry *dst) | 90 | static inline struct neighbour *dst_get_neighbour_noref(struct dst_entry *dst) |
90 | { | 91 | { |
91 | return rcu_dereference(dst->_neighbour); | 92 | return rcu_dereference(dst->_neighbour); |
92 | } | 93 | } |
93 | 94 | ||
94 | static inline struct neighbour *dst_get_neighbour_raw(struct dst_entry *dst) | 95 | static inline struct neighbour *dst_get_neighbour_noref_raw(struct dst_entry *dst) |
95 | { | 96 | { |
96 | return rcu_dereference_raw(dst->_neighbour); | 97 | return rcu_dereference_raw(dst->_neighbour); |
97 | } | 98 | } |
@@ -205,12 +206,7 @@ dst_feature(const struct dst_entry *dst, u32 feature) | |||
205 | 206 | ||
206 | static inline u32 dst_mtu(const struct dst_entry *dst) | 207 | static inline u32 dst_mtu(const struct dst_entry *dst) |
207 | { | 208 | { |
208 | u32 mtu = dst_metric_raw(dst, RTAX_MTU); | 209 | return dst->ops->mtu(dst); |
209 | |||
210 | if (!mtu) | ||
211 | mtu = dst->ops->default_mtu(dst); | ||
212 | |||
213 | return mtu; | ||
214 | } | 210 | } |
215 | 211 | ||
216 | /* RTT metrics are stored in milliseconds for user ABI, but used as jiffies */ | 212 | /* RTT metrics are stored in milliseconds for user ABI, but used as jiffies */ |
@@ -397,7 +393,7 @@ static inline void dst_confirm(struct dst_entry *dst) | |||
397 | struct neighbour *n; | 393 | struct neighbour *n; |
398 | 394 | ||
399 | rcu_read_lock(); | 395 | rcu_read_lock(); |
400 | n = dst_get_neighbour(dst); | 396 | n = dst_get_neighbour_noref(dst); |
401 | neigh_confirm(n); | 397 | neigh_confirm(n); |
402 | rcu_read_unlock(); | 398 | rcu_read_unlock(); |
403 | } | 399 | } |
diff --git a/include/net/dst_ops.h b/include/net/dst_ops.h index 9adb99845a56..e1c2ee0eef47 100644 --- a/include/net/dst_ops.h +++ b/include/net/dst_ops.h | |||
@@ -17,7 +17,7 @@ struct dst_ops { | |||
17 | int (*gc)(struct dst_ops *ops); | 17 | int (*gc)(struct dst_ops *ops); |
18 | struct dst_entry * (*check)(struct dst_entry *, __u32 cookie); | 18 | struct dst_entry * (*check)(struct dst_entry *, __u32 cookie); |
19 | unsigned int (*default_advmss)(const struct dst_entry *); | 19 | unsigned int (*default_advmss)(const struct dst_entry *); |
20 | unsigned int (*default_mtu)(const struct dst_entry *); | 20 | unsigned int (*mtu)(const struct dst_entry *); |
21 | u32 * (*cow_metrics)(struct dst_entry *, unsigned long); | 21 | u32 * (*cow_metrics)(struct dst_entry *, unsigned long); |
22 | void (*destroy)(struct dst_entry *); | 22 | void (*destroy)(struct dst_entry *); |
23 | void (*ifdown)(struct dst_entry *, | 23 | void (*ifdown)(struct dst_entry *, |
diff --git a/include/net/flow.h b/include/net/flow.h index a09447749e2d..da1f064a81b3 100644 --- a/include/net/flow.h +++ b/include/net/flow.h | |||
@@ -59,8 +59,11 @@ struct flowi4 { | |||
59 | #define flowi4_proto __fl_common.flowic_proto | 59 | #define flowi4_proto __fl_common.flowic_proto |
60 | #define flowi4_flags __fl_common.flowic_flags | 60 | #define flowi4_flags __fl_common.flowic_flags |
61 | #define flowi4_secid __fl_common.flowic_secid | 61 | #define flowi4_secid __fl_common.flowic_secid |
62 | __be32 daddr; | 62 | |
63 | /* (saddr,daddr) must be grouped, same order as in IP header */ | ||
63 | __be32 saddr; | 64 | __be32 saddr; |
65 | __be32 daddr; | ||
66 | |||
64 | union flowi_uli uli; | 67 | union flowi_uli uli; |
65 | #define fl4_sport uli.ports.sport | 68 | #define fl4_sport uli.ports.sport |
66 | #define fl4_dport uli.ports.dport | 69 | #define fl4_dport uli.ports.dport |
@@ -207,6 +210,7 @@ extern struct flow_cache_object *flow_cache_lookup( | |||
207 | u8 dir, flow_resolve_t resolver, void *ctx); | 210 | u8 dir, flow_resolve_t resolver, void *ctx); |
208 | 211 | ||
209 | extern void flow_cache_flush(void); | 212 | extern void flow_cache_flush(void); |
213 | extern void flow_cache_flush_deferred(void); | ||
210 | extern atomic_t flow_cache_genid; | 214 | extern atomic_t flow_cache_genid; |
211 | 215 | ||
212 | #endif | 216 | #endif |
diff --git a/include/net/flow_keys.h b/include/net/flow_keys.h new file mode 100644 index 000000000000..80461c1ae9ef --- /dev/null +++ b/include/net/flow_keys.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef _NET_FLOW_KEYS_H | ||
2 | #define _NET_FLOW_KEYS_H | ||
3 | |||
4 | struct flow_keys { | ||
5 | /* (src,dst) must be grouped, in the same way than in IP header */ | ||
6 | __be32 src; | ||
7 | __be32 dst; | ||
8 | union { | ||
9 | __be32 ports; | ||
10 | __be16 port16[2]; | ||
11 | }; | ||
12 | u8 ip_proto; | ||
13 | }; | ||
14 | |||
15 | extern bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow); | ||
16 | #endif | ||
diff --git a/include/net/genetlink.h b/include/net/genetlink.h index 82d8d09faa44..7db32995ccd3 100644 --- a/include/net/genetlink.h +++ b/include/net/genetlink.h | |||
@@ -128,6 +128,8 @@ extern int genl_register_mc_group(struct genl_family *family, | |||
128 | struct genl_multicast_group *grp); | 128 | struct genl_multicast_group *grp); |
129 | extern void genl_unregister_mc_group(struct genl_family *family, | 129 | extern void genl_unregister_mc_group(struct genl_family *family, |
130 | struct genl_multicast_group *grp); | 130 | struct genl_multicast_group *grp); |
131 | extern void genl_notify(struct sk_buff *skb, struct net *net, u32 pid, | ||
132 | u32 group, struct nlmsghdr *nlh, gfp_t flags); | ||
131 | 133 | ||
132 | /** | 134 | /** |
133 | * genlmsg_put - Add generic netlink header to netlink message | 135 | * genlmsg_put - Add generic netlink header to netlink message |
diff --git a/include/net/icmp.h b/include/net/icmp.h index f0698b955b73..75d615649071 100644 --- a/include/net/icmp.h +++ b/include/net/icmp.h | |||
@@ -31,8 +31,8 @@ struct icmp_err { | |||
31 | extern const struct icmp_err icmp_err_convert[]; | 31 | extern const struct icmp_err icmp_err_convert[]; |
32 | #define ICMP_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.icmp_statistics, field) | 32 | #define ICMP_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.icmp_statistics, field) |
33 | #define ICMP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.icmp_statistics, field) | 33 | #define ICMP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.icmp_statistics, field) |
34 | #define ICMPMSGOUT_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.icmpmsg_statistics, field+256) | 34 | #define ICMPMSGOUT_INC_STATS(net, field) SNMP_INC_STATS_ATOMIC_LONG((net)->mib.icmpmsg_statistics, field+256) |
35 | #define ICMPMSGIN_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.icmpmsg_statistics, field) | 35 | #define ICMPMSGIN_INC_STATS_BH(net, field) SNMP_INC_STATS_ATOMIC_LONG((net)->mib.icmpmsg_statistics, field) |
36 | 36 | ||
37 | struct dst_entry; | 37 | struct dst_entry; |
38 | struct net_proto_family; | 38 | struct net_proto_family; |
diff --git a/include/net/ieee802154.h b/include/net/ieee802154.h index d52685defb11..ee59f8b188dd 100644 --- a/include/net/ieee802154.h +++ b/include/net/ieee802154.h | |||
@@ -21,11 +21,14 @@ | |||
21 | * Maxim Gorbachyov <maxim.gorbachev@siemens.com> | 21 | * Maxim Gorbachyov <maxim.gorbachev@siemens.com> |
22 | * Maxim Osipov <maxim.osipov@siemens.com> | 22 | * Maxim Osipov <maxim.osipov@siemens.com> |
23 | * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 23 | * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> |
24 | * Alexander Smirnov <alex.bluesman.smirnov@gmail.com> | ||
24 | */ | 25 | */ |
25 | 26 | ||
26 | #ifndef NET_IEEE802154_H | 27 | #ifndef NET_IEEE802154_H |
27 | #define NET_IEEE802154_H | 28 | #define NET_IEEE802154_H |
28 | 29 | ||
30 | #define IEEE802154_MTU 127 | ||
31 | |||
29 | #define IEEE802154_FC_TYPE_BEACON 0x0 /* Frame is beacon */ | 32 | #define IEEE802154_FC_TYPE_BEACON 0x0 /* Frame is beacon */ |
30 | #define IEEE802154_FC_TYPE_DATA 0x1 /* Frame is data */ | 33 | #define IEEE802154_FC_TYPE_DATA 0x1 /* Frame is data */ |
31 | #define IEEE802154_FC_TYPE_ACK 0x2 /* Frame is acknowledgment */ | 34 | #define IEEE802154_FC_TYPE_ACK 0x2 /* Frame is acknowledgment */ |
@@ -56,6 +59,9 @@ | |||
56 | (((x) & IEEE802154_FC_DAMODE_MASK) >> IEEE802154_FC_DAMODE_SHIFT) | 59 | (((x) & IEEE802154_FC_DAMODE_MASK) >> IEEE802154_FC_DAMODE_SHIFT) |
57 | 60 | ||
58 | 61 | ||
62 | /* MAC footer size */ | ||
63 | #define IEEE802154_MFR_SIZE 2 /* 2 octets */ | ||
64 | |||
59 | /* MAC's Command Frames Identifiers */ | 65 | /* MAC's Command Frames Identifiers */ |
60 | #define IEEE802154_CMD_ASSOCIATION_REQ 0x01 | 66 | #define IEEE802154_CMD_ASSOCIATION_REQ 0x01 |
61 | #define IEEE802154_CMD_ASSOCIATION_RESP 0x02 | 67 | #define IEEE802154_CMD_ASSOCIATION_RESP 0x02 |
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h index e46674d5daea..00cbb4384c79 100644 --- a/include/net/inet6_hashtables.h +++ b/include/net/inet6_hashtables.h | |||
@@ -15,7 +15,7 @@ | |||
15 | #define _INET6_HASHTABLES_H | 15 | #define _INET6_HASHTABLES_H |
16 | 16 | ||
17 | 17 | ||
18 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 18 | #if IS_ENABLED(CONFIG_IPV6) |
19 | #include <linux/in6.h> | 19 | #include <linux/in6.h> |
20 | #include <linux/ipv6.h> | 20 | #include <linux/ipv6.h> |
21 | #include <linux/types.h> | 21 | #include <linux/types.h> |
@@ -110,5 +110,5 @@ extern struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo | |||
110 | const struct in6_addr *saddr, const __be16 sport, | 110 | const struct in6_addr *saddr, const __be16 sport, |
111 | const struct in6_addr *daddr, const __be16 dport, | 111 | const struct in6_addr *daddr, const __be16 dport, |
112 | const int dif); | 112 | const int dif); |
113 | #endif /* defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) */ | 113 | #endif /* IS_ENABLED(CONFIG_IPV6) */ |
114 | #endif /* _INET6_HASHTABLES_H */ | 114 | #endif /* _INET6_HASHTABLES_H */ |
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index e6db62e756dc..dbf9aab34c82 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h | |||
@@ -143,9 +143,9 @@ static inline void *inet_csk_ca(const struct sock *sk) | |||
143 | return (void *)inet_csk(sk)->icsk_ca_priv; | 143 | return (void *)inet_csk(sk)->icsk_ca_priv; |
144 | } | 144 | } |
145 | 145 | ||
146 | extern struct sock *inet_csk_clone(struct sock *sk, | 146 | extern struct sock *inet_csk_clone_lock(const struct sock *sk, |
147 | const struct request_sock *req, | 147 | const struct request_sock *req, |
148 | const gfp_t priority); | 148 | const gfp_t priority); |
149 | 149 | ||
150 | enum inet_csk_ack_state_t { | 150 | enum inet_csk_ack_state_t { |
151 | ICSK_ACK_SCHED = 1, | 151 | ICSK_ACK_SCHED = 1, |
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index b897d6e6d0a5..e3e405106afe 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h | |||
@@ -31,6 +31,7 @@ | |||
31 | /** struct ip_options - IP Options | 31 | /** struct ip_options - IP Options |
32 | * | 32 | * |
33 | * @faddr - Saved first hop address | 33 | * @faddr - Saved first hop address |
34 | * @nexthop - Saved nexthop address in LSRR and SSRR | ||
34 | * @is_data - Options in __data, rather than skb | 35 | * @is_data - Options in __data, rather than skb |
35 | * @is_strictroute - Strict source route | 36 | * @is_strictroute - Strict source route |
36 | * @srr_is_hit - Packet destination addr was our one | 37 | * @srr_is_hit - Packet destination addr was our one |
@@ -41,6 +42,7 @@ | |||
41 | */ | 42 | */ |
42 | struct ip_options { | 43 | struct ip_options { |
43 | __be32 faddr; | 44 | __be32 faddr; |
45 | __be32 nexthop; | ||
44 | unsigned char optlen; | 46 | unsigned char optlen; |
45 | unsigned char srr; | 47 | unsigned char srr; |
46 | unsigned char rr; | 48 | unsigned char rr; |
@@ -69,7 +71,7 @@ struct ip_options_data { | |||
69 | 71 | ||
70 | struct inet_request_sock { | 72 | struct inet_request_sock { |
71 | struct request_sock req; | 73 | struct request_sock req; |
72 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 74 | #if IS_ENABLED(CONFIG_IPV6) |
73 | u16 inet6_rsk_offset; | 75 | u16 inet6_rsk_offset; |
74 | #endif | 76 | #endif |
75 | __be16 loc_port; | 77 | __be16 loc_port; |
@@ -137,7 +139,7 @@ struct rtable; | |||
137 | struct inet_sock { | 139 | struct inet_sock { |
138 | /* sk and pinet6 has to be the first two members of inet_sock */ | 140 | /* sk and pinet6 has to be the first two members of inet_sock */ |
139 | struct sock sk; | 141 | struct sock sk; |
140 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 142 | #if IS_ENABLED(CONFIG_IPV6) |
141 | struct ipv6_pinfo *pinet6; | 143 | struct ipv6_pinfo *pinet6; |
142 | #endif | 144 | #endif |
143 | /* Socket demultiplex comparisons on incoming packets. */ | 145 | /* Socket demultiplex comparisons on incoming packets. */ |
@@ -186,7 +188,7 @@ static inline void __inet_sk_copy_descendant(struct sock *sk_to, | |||
186 | memcpy(inet_sk(sk_to) + 1, inet_sk(sk_from) + 1, | 188 | memcpy(inet_sk(sk_to) + 1, inet_sk(sk_from) + 1, |
187 | sk_from->sk_prot->obj_size - ancestor_size); | 189 | sk_from->sk_prot->obj_size - ancestor_size); |
188 | } | 190 | } |
189 | #if !(defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)) | 191 | #if !(IS_ENABLED(CONFIG_IPV6)) |
190 | static inline void inet_sk_copy_descendant(struct sock *sk_to, | 192 | static inline void inet_sk_copy_descendant(struct sock *sk_to, |
191 | const struct sock *sk_from) | 193 | const struct sock *sk_from) |
192 | { | 194 | { |
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h index e8c25b981205..ba52c830a7a5 100644 --- a/include/net/inet_timewait_sock.h +++ b/include/net/inet_timewait_sock.h | |||
@@ -218,20 +218,12 @@ extern void inet_twsk_purge(struct inet_hashinfo *hashinfo, | |||
218 | static inline | 218 | static inline |
219 | struct net *twsk_net(const struct inet_timewait_sock *twsk) | 219 | struct net *twsk_net(const struct inet_timewait_sock *twsk) |
220 | { | 220 | { |
221 | #ifdef CONFIG_NET_NS | 221 | return read_pnet(&twsk->tw_net); |
222 | return rcu_dereference_raw(twsk->tw_net); /* protected by locking, */ | ||
223 | /* reference counting, */ | ||
224 | /* initialization, or RCU. */ | ||
225 | #else | ||
226 | return &init_net; | ||
227 | #endif | ||
228 | } | 222 | } |
229 | 223 | ||
230 | static inline | 224 | static inline |
231 | void twsk_net_set(struct inet_timewait_sock *twsk, struct net *net) | 225 | void twsk_net_set(struct inet_timewait_sock *twsk, struct net *net) |
232 | { | 226 | { |
233 | #ifdef CONFIG_NET_NS | 227 | write_pnet(&twsk->tw_net, net); |
234 | rcu_assign_pointer(twsk->tw_net, net); | ||
235 | #endif | ||
236 | } | 228 | } |
237 | #endif /* _INET_TIMEWAIT_SOCK_ */ | 229 | #endif /* _INET_TIMEWAIT_SOCK_ */ |
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h index 78c83e62218f..06b795dd5906 100644 --- a/include/net/inetpeer.h +++ b/include/net/inetpeer.h | |||
@@ -35,6 +35,7 @@ struct inet_peer { | |||
35 | 35 | ||
36 | u32 metrics[RTAX_MAX]; | 36 | u32 metrics[RTAX_MAX]; |
37 | u32 rate_tokens; /* rate limiting for ICMP */ | 37 | u32 rate_tokens; /* rate limiting for ICMP */ |
38 | int redirect_genid; | ||
38 | unsigned long rate_last; | 39 | unsigned long rate_last; |
39 | unsigned long pmtu_expires; | 40 | unsigned long pmtu_expires; |
40 | u32 pmtu_orig; | 41 | u32 pmtu_orig; |
@@ -86,7 +87,7 @@ static inline struct inet_peer *inet_getpeer_v6(const struct in6_addr *v6daddr, | |||
86 | { | 87 | { |
87 | struct inetpeer_addr daddr; | 88 | struct inetpeer_addr daddr; |
88 | 89 | ||
89 | ipv6_addr_copy((struct in6_addr *)daddr.addr.a6, v6daddr); | 90 | *(struct in6_addr *)daddr.addr.a6 = *v6daddr; |
90 | daddr.family = AF_INET6; | 91 | daddr.family = AF_INET6; |
91 | return inet_getpeer(&daddr, create); | 92 | return inet_getpeer(&daddr, create); |
92 | } | 93 | } |
diff --git a/include/net/ip.h b/include/net/ip.h index eca0ef7a495e..775009f9eaba 100644 --- a/include/net/ip.h +++ b/include/net/ip.h | |||
@@ -353,14 +353,14 @@ static inline void ip_ipgre_mc_map(__be32 naddr, const unsigned char *broadcast, | |||
353 | memcpy(buf, &naddr, sizeof(naddr)); | 353 | memcpy(buf, &naddr, sizeof(naddr)); |
354 | } | 354 | } |
355 | 355 | ||
356 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 356 | #if IS_ENABLED(CONFIG_IPV6) |
357 | #include <linux/ipv6.h> | 357 | #include <linux/ipv6.h> |
358 | #endif | 358 | #endif |
359 | 359 | ||
360 | static __inline__ void inet_reset_saddr(struct sock *sk) | 360 | static __inline__ void inet_reset_saddr(struct sock *sk) |
361 | { | 361 | { |
362 | inet_sk(sk)->inet_rcv_saddr = inet_sk(sk)->inet_saddr = 0; | 362 | inet_sk(sk)->inet_rcv_saddr = inet_sk(sk)->inet_saddr = 0; |
363 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 363 | #if IS_ENABLED(CONFIG_IPV6) |
364 | if (sk->sk_family == PF_INET6) { | 364 | if (sk->sk_family == PF_INET6) { |
365 | struct ipv6_pinfo *np = inet6_sk(sk); | 365 | struct ipv6_pinfo *np = inet6_sk(sk); |
366 | 366 | ||
@@ -379,7 +379,7 @@ static inline int sk_mc_loop(struct sock *sk) | |||
379 | switch (sk->sk_family) { | 379 | switch (sk->sk_family) { |
380 | case AF_INET: | 380 | case AF_INET: |
381 | return inet_sk(sk)->mc_loop; | 381 | return inet_sk(sk)->mc_loop; |
382 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 382 | #if IS_ENABLED(CONFIG_IPV6) |
383 | case AF_INET6: | 383 | case AF_INET6: |
384 | return inet6_sk(sk)->mc_loop; | 384 | return inet6_sk(sk)->mc_loop; |
385 | #endif | 385 | #endif |
@@ -450,7 +450,7 @@ extern int ip_options_rcv_srr(struct sk_buff *skb); | |||
450 | * Functions provided by ip_sockglue.c | 450 | * Functions provided by ip_sockglue.c |
451 | */ | 451 | */ |
452 | 452 | ||
453 | extern int ip_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); | 453 | extern void ipv4_pktinfo_prepare(struct sk_buff *skb); |
454 | extern void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb); | 454 | extern void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb); |
455 | extern int ip_cmsg_send(struct net *net, | 455 | extern int ip_cmsg_send(struct net *net, |
456 | struct msghdr *msg, struct ipcm_cookie *ipc); | 456 | struct msghdr *msg, struct ipcm_cookie *ipc); |
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h index 5735a0f979c3..b26bb8101981 100644 --- a/include/net/ip6_fib.h +++ b/include/net/ip6_fib.h | |||
@@ -86,9 +86,6 @@ struct fib6_table; | |||
86 | struct rt6_info { | 86 | struct rt6_info { |
87 | struct dst_entry dst; | 87 | struct dst_entry dst; |
88 | 88 | ||
89 | #define rt6i_dev dst.dev | ||
90 | #define rt6i_expires dst.expires | ||
91 | |||
92 | /* | 89 | /* |
93 | * Tail elements of dst_entry (__refcnt etc.) | 90 | * Tail elements of dst_entry (__refcnt etc.) |
94 | * and these elements (rarely used in hot path) are in | 91 | * and these elements (rarely used in hot path) are in |
@@ -202,6 +199,10 @@ struct fib6_node *fib6_locate(struct fib6_node *root, | |||
202 | const struct in6_addr *daddr, int dst_len, | 199 | const struct in6_addr *daddr, int dst_len, |
203 | const struct in6_addr *saddr, int src_len); | 200 | const struct in6_addr *saddr, int src_len); |
204 | 201 | ||
202 | extern void fib6_clean_all_ro(struct net *net, | ||
203 | int (*func)(struct rt6_info *, void *arg), | ||
204 | int prune, void *arg); | ||
205 | |||
205 | extern void fib6_clean_all(struct net *net, | 206 | extern void fib6_clean_all(struct net *net, |
206 | int (*func)(struct rt6_info *, void *arg), | 207 | int (*func)(struct rt6_info *, void *arg), |
207 | int prune, void *arg); | 208 | int prune, void *arg); |
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h index 5e91b72fc718..2ad92ca4e6f3 100644 --- a/include/net/ip6_route.h +++ b/include/net/ip6_route.h | |||
@@ -70,6 +70,8 @@ extern void ip6_route_input(struct sk_buff *skb); | |||
70 | extern struct dst_entry * ip6_route_output(struct net *net, | 70 | extern struct dst_entry * ip6_route_output(struct net *net, |
71 | const struct sock *sk, | 71 | const struct sock *sk, |
72 | struct flowi6 *fl6); | 72 | struct flowi6 *fl6); |
73 | extern struct dst_entry * ip6_route_lookup(struct net *net, | ||
74 | struct flowi6 *fl6, int flags); | ||
73 | 75 | ||
74 | extern int ip6_route_init(void); | 76 | extern int ip6_route_init(void); |
75 | extern void ip6_route_cleanup(void); | 77 | extern void ip6_route_cleanup(void); |
@@ -95,14 +97,14 @@ extern struct rt6_info *rt6_lookup(struct net *net, | |||
95 | 97 | ||
96 | extern struct dst_entry *icmp6_dst_alloc(struct net_device *dev, | 98 | extern struct dst_entry *icmp6_dst_alloc(struct net_device *dev, |
97 | struct neighbour *neigh, | 99 | struct neighbour *neigh, |
98 | const struct in6_addr *addr); | 100 | struct flowi6 *fl6); |
99 | extern int icmp6_dst_gc(void); | 101 | extern int icmp6_dst_gc(void); |
100 | 102 | ||
101 | extern void fib6_force_start_gc(struct net *net); | 103 | extern void fib6_force_start_gc(struct net *net); |
102 | 104 | ||
103 | extern struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, | 105 | extern struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, |
104 | const struct in6_addr *addr, | 106 | const struct in6_addr *addr, |
105 | int anycast); | 107 | bool anycast); |
106 | 108 | ||
107 | extern int ip6_dst_hoplimit(struct dst_entry *dst); | 109 | extern int ip6_dst_hoplimit(struct dst_entry *dst); |
108 | 110 | ||
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index 873d5be7926c..ebe517f2da9f 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/netfilter.h> /* for union nf_inet_addr */ | 21 | #include <linux/netfilter.h> /* for union nf_inet_addr */ |
22 | #include <linux/ip.h> | 22 | #include <linux/ip.h> |
23 | #include <linux/ipv6.h> /* for struct ipv6hdr */ | 23 | #include <linux/ipv6.h> /* for struct ipv6hdr */ |
24 | #include <net/ipv6.h> /* for ipv6_addr_copy */ | 24 | #include <net/ipv6.h> |
25 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | 25 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
26 | #include <net/netfilter/nf_conntrack.h> | 26 | #include <net/netfilter/nf_conntrack.h> |
27 | #endif | 27 | #endif |
@@ -119,8 +119,8 @@ ip_vs_fill_iphdr(int af, const void *nh, struct ip_vs_iphdr *iphdr) | |||
119 | const struct ipv6hdr *iph = nh; | 119 | const struct ipv6hdr *iph = nh; |
120 | iphdr->len = sizeof(struct ipv6hdr); | 120 | iphdr->len = sizeof(struct ipv6hdr); |
121 | iphdr->protocol = iph->nexthdr; | 121 | iphdr->protocol = iph->nexthdr; |
122 | ipv6_addr_copy(&iphdr->saddr.in6, &iph->saddr); | 122 | iphdr->saddr.in6 = iph->saddr; |
123 | ipv6_addr_copy(&iphdr->daddr.in6, &iph->daddr); | 123 | iphdr->daddr.in6 = iph->daddr; |
124 | } else | 124 | } else |
125 | #endif | 125 | #endif |
126 | { | 126 | { |
@@ -137,7 +137,7 @@ static inline void ip_vs_addr_copy(int af, union nf_inet_addr *dst, | |||
137 | { | 137 | { |
138 | #ifdef CONFIG_IP_VS_IPV6 | 138 | #ifdef CONFIG_IP_VS_IPV6 |
139 | if (af == AF_INET6) | 139 | if (af == AF_INET6) |
140 | ipv6_addr_copy(&dst->in6, &src->in6); | 140 | dst->in6 = src->in6; |
141 | else | 141 | else |
142 | #endif | 142 | #endif |
143 | dst->ip = src->ip; | 143 | dst->ip = src->ip; |
@@ -1207,7 +1207,7 @@ extern void ip_vs_control_cleanup(void); | |||
1207 | extern struct ip_vs_dest * | 1207 | extern struct ip_vs_dest * |
1208 | ip_vs_find_dest(struct net *net, int af, const union nf_inet_addr *daddr, | 1208 | ip_vs_find_dest(struct net *net, int af, const union nf_inet_addr *daddr, |
1209 | __be16 dport, const union nf_inet_addr *vaddr, __be16 vport, | 1209 | __be16 dport, const union nf_inet_addr *vaddr, __be16 vport, |
1210 | __u16 protocol, __u32 fwmark); | 1210 | __u16 protocol, __u32 fwmark, __u32 flags); |
1211 | extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); | 1211 | extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); |
1212 | 1212 | ||
1213 | 1213 | ||
diff --git a/include/net/ipv6.h b/include/net/ipv6.h index a366a8a1fe23..e4170a22fc6f 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h | |||
@@ -132,6 +132,15 @@ extern struct ctl_path net_ipv6_ctl_path[]; | |||
132 | SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field));\ | 132 | SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field));\ |
133 | }) | 133 | }) |
134 | 134 | ||
135 | /* per device and per net counters are atomic_long_t */ | ||
136 | #define _DEVINC_ATOMIC_ATOMIC(net, statname, idev, field) \ | ||
137 | ({ \ | ||
138 | struct inet6_dev *_idev = (idev); \ | ||
139 | if (likely(_idev != NULL)) \ | ||
140 | SNMP_INC_STATS_ATOMIC_LONG((_idev)->stats.statname##dev, (field)); \ | ||
141 | SNMP_INC_STATS_ATOMIC_LONG((net)->mib.statname##_statistics, (field));\ | ||
142 | }) | ||
143 | |||
135 | #define _DEVADD(net, statname, modifier, idev, field, val) \ | 144 | #define _DEVADD(net, statname, modifier, idev, field, val) \ |
136 | ({ \ | 145 | ({ \ |
137 | struct inet6_dev *_idev = (idev); \ | 146 | struct inet6_dev *_idev = (idev); \ |
@@ -168,11 +177,11 @@ extern struct ctl_path net_ipv6_ctl_path[]; | |||
168 | _DEVINCATOMIC(net, icmpv6, _BH, idev, field) | 177 | _DEVINCATOMIC(net, icmpv6, _BH, idev, field) |
169 | 178 | ||
170 | #define ICMP6MSGOUT_INC_STATS(net, idev, field) \ | 179 | #define ICMP6MSGOUT_INC_STATS(net, idev, field) \ |
171 | _DEVINCATOMIC(net, icmpv6msg, , idev, field +256) | 180 | _DEVINC_ATOMIC_ATOMIC(net, icmpv6msg, idev, field +256) |
172 | #define ICMP6MSGOUT_INC_STATS_BH(net, idev, field) \ | 181 | #define ICMP6MSGOUT_INC_STATS_BH(net, idev, field) \ |
173 | _DEVINCATOMIC(net, icmpv6msg, _BH, idev, field +256) | 182 | _DEVINC_ATOMIC_ATOMIC(net, icmpv6msg, idev, field +256) |
174 | #define ICMP6MSGIN_INC_STATS_BH(net, idev, field) \ | 183 | #define ICMP6MSGIN_INC_STATS_BH(net, idev, field) \ |
175 | _DEVINCATOMIC(net, icmpv6msg, _BH, idev, field) | 184 | _DEVINC_ATOMIC_ATOMIC(net, icmpv6msg, idev, field) |
176 | 185 | ||
177 | struct ip6_ra_chain { | 186 | struct ip6_ra_chain { |
178 | struct ip6_ra_chain *next; | 187 | struct ip6_ra_chain *next; |
@@ -300,11 +309,6 @@ ipv6_masked_addr_cmp(const struct in6_addr *a1, const struct in6_addr *m, | |||
300 | ((a1->s6_addr32[3] ^ a2->s6_addr32[3]) & m->s6_addr32[3])); | 309 | ((a1->s6_addr32[3] ^ a2->s6_addr32[3]) & m->s6_addr32[3])); |
301 | } | 310 | } |
302 | 311 | ||
303 | static inline void ipv6_addr_copy(struct in6_addr *a1, const struct in6_addr *a2) | ||
304 | { | ||
305 | memcpy(a1, a2, sizeof(struct in6_addr)); | ||
306 | } | ||
307 | |||
308 | static inline void ipv6_addr_prefix(struct in6_addr *pfx, | 312 | static inline void ipv6_addr_prefix(struct in6_addr *pfx, |
309 | const struct in6_addr *addr, | 313 | const struct in6_addr *addr, |
310 | int plen) | 314 | int plen) |
@@ -554,7 +558,7 @@ extern void ipv6_push_frag_opts(struct sk_buff *skb, | |||
554 | u8 *proto); | 558 | u8 *proto); |
555 | 559 | ||
556 | extern int ipv6_skip_exthdr(const struct sk_buff *, int start, | 560 | extern int ipv6_skip_exthdr(const struct sk_buff *, int start, |
557 | u8 *nexthdrp); | 561 | u8 *nexthdrp, __be16 *frag_offp); |
558 | 562 | ||
559 | extern int ipv6_ext_hdr(u8 nexthdr); | 563 | extern int ipv6_ext_hdr(u8 nexthdr); |
560 | 564 | ||
diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h index f2419cf44cef..0954ec959159 100644 --- a/include/net/iucv/af_iucv.h +++ b/include/net/iucv/af_iucv.h | |||
@@ -27,7 +27,6 @@ enum { | |||
27 | IUCV_OPEN, | 27 | IUCV_OPEN, |
28 | IUCV_BOUND, | 28 | IUCV_BOUND, |
29 | IUCV_LISTEN, | 29 | IUCV_LISTEN, |
30 | IUCV_SEVERED, | ||
31 | IUCV_DISCONN, | 30 | IUCV_DISCONN, |
32 | IUCV_CLOSING, | 31 | IUCV_CLOSING, |
33 | IUCV_CLOSED | 32 | IUCV_CLOSED |
@@ -146,7 +145,6 @@ unsigned int iucv_sock_poll(struct file *file, struct socket *sock, | |||
146 | poll_table *wait); | 145 | poll_table *wait); |
147 | void iucv_sock_link(struct iucv_sock_list *l, struct sock *s); | 146 | void iucv_sock_link(struct iucv_sock_list *l, struct sock *s); |
148 | void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s); | 147 | void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s); |
149 | int iucv_sock_wait_cnt(struct sock *sk, unsigned long timeo); | ||
150 | void iucv_accept_enqueue(struct sock *parent, struct sock *sk); | 148 | void iucv_accept_enqueue(struct sock *parent, struct sock *sk); |
151 | void iucv_accept_unlink(struct sock *sk); | 149 | void iucv_accept_unlink(struct sock *sk); |
152 | struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock); | 150 | struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock); |
diff --git a/include/net/ndisc.h b/include/net/ndisc.h index 62beeb97c4b1..e3133c23980e 100644 --- a/include/net/ndisc.h +++ b/include/net/ndisc.h | |||
@@ -79,6 +79,42 @@ struct nd_opt_hdr { | |||
79 | __u8 nd_opt_len; | 79 | __u8 nd_opt_len; |
80 | } __packed; | 80 | } __packed; |
81 | 81 | ||
82 | static inline u32 ndisc_hashfn(const void *pkey, const struct net_device *dev, __u32 *hash_rnd) | ||
83 | { | ||
84 | const u32 *p32 = pkey; | ||
85 | |||
86 | return (((p32[0] ^ dev->ifindex) * hash_rnd[0]) + | ||
87 | (p32[1] * hash_rnd[1]) + | ||
88 | (p32[2] * hash_rnd[2]) + | ||
89 | (p32[3] * hash_rnd[3])); | ||
90 | } | ||
91 | |||
92 | static inline struct neighbour *__ipv6_neigh_lookup(struct neigh_table *tbl, struct net_device *dev, const void *pkey) | ||
93 | { | ||
94 | struct neigh_hash_table *nht; | ||
95 | const u32 *p32 = pkey; | ||
96 | struct neighbour *n; | ||
97 | u32 hash_val; | ||
98 | |||
99 | rcu_read_lock_bh(); | ||
100 | nht = rcu_dereference_bh(tbl->nht); | ||
101 | hash_val = ndisc_hashfn(pkey, dev, nht->hash_rnd) >> (32 - nht->hash_shift); | ||
102 | for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]); | ||
103 | n != NULL; | ||
104 | n = rcu_dereference_bh(n->next)) { | ||
105 | u32 *n32 = (u32 *) n->primary_key; | ||
106 | if (n->dev == dev && | ||
107 | ((n32[0] ^ p32[0]) | (n32[1] ^ p32[1]) | | ||
108 | (n32[2] ^ p32[2]) | (n32[3] ^ p32[3])) == 0) { | ||
109 | if (!atomic_inc_not_zero(&n->refcnt)) | ||
110 | n = NULL; | ||
111 | break; | ||
112 | } | ||
113 | } | ||
114 | rcu_read_unlock_bh(); | ||
115 | |||
116 | return n; | ||
117 | } | ||
82 | 118 | ||
83 | extern int ndisc_init(void); | 119 | extern int ndisc_init(void); |
84 | 120 | ||
@@ -145,13 +181,4 @@ int ndisc_ifinfo_sysctl_strategy(ctl_table *ctl, | |||
145 | extern void inet6_ifinfo_notify(int event, | 181 | extern void inet6_ifinfo_notify(int event, |
146 | struct inet6_dev *idev); | 182 | struct inet6_dev *idev); |
147 | 183 | ||
148 | static inline struct neighbour * ndisc_get_neigh(struct net_device *dev, const struct in6_addr *addr) | ||
149 | { | ||
150 | |||
151 | if (dev) | ||
152 | return __neigh_lookup_errno(&nd_tbl, addr, dev); | ||
153 | |||
154 | return ERR_PTR(-ENODEV); | ||
155 | } | ||
156 | |||
157 | #endif | 184 | #endif |
diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 2720884287c3..34c996f46181 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h | |||
@@ -59,7 +59,7 @@ struct neigh_parms { | |||
59 | int reachable_time; | 59 | int reachable_time; |
60 | int delay_probe_time; | 60 | int delay_probe_time; |
61 | 61 | ||
62 | int queue_len; | 62 | int queue_len_bytes; |
63 | int ucast_probes; | 63 | int ucast_probes; |
64 | int app_probes; | 64 | int app_probes; |
65 | int mcast_probes; | 65 | int mcast_probes; |
@@ -99,6 +99,7 @@ struct neighbour { | |||
99 | rwlock_t lock; | 99 | rwlock_t lock; |
100 | atomic_t refcnt; | 100 | atomic_t refcnt; |
101 | struct sk_buff_head arp_queue; | 101 | struct sk_buff_head arp_queue; |
102 | unsigned int arp_queue_len_bytes; | ||
102 | struct timer_list timer; | 103 | struct timer_list timer; |
103 | unsigned long used; | 104 | unsigned long used; |
104 | atomic_t probes; | 105 | atomic_t probes; |
@@ -138,10 +139,12 @@ struct pneigh_entry { | |||
138 | * neighbour table manipulation | 139 | * neighbour table manipulation |
139 | */ | 140 | */ |
140 | 141 | ||
142 | #define NEIGH_NUM_HASH_RND 4 | ||
143 | |||
141 | struct neigh_hash_table { | 144 | struct neigh_hash_table { |
142 | struct neighbour __rcu **hash_buckets; | 145 | struct neighbour __rcu **hash_buckets; |
143 | unsigned int hash_shift; | 146 | unsigned int hash_shift; |
144 | __u32 hash_rnd; | 147 | __u32 hash_rnd[NEIGH_NUM_HASH_RND]; |
145 | struct rcu_head rcu; | 148 | struct rcu_head rcu; |
146 | }; | 149 | }; |
147 | 150 | ||
@@ -153,7 +156,7 @@ struct neigh_table { | |||
153 | int key_len; | 156 | int key_len; |
154 | __u32 (*hash)(const void *pkey, | 157 | __u32 (*hash)(const void *pkey, |
155 | const struct net_device *dev, | 158 | const struct net_device *dev, |
156 | __u32 hash_rnd); | 159 | __u32 *hash_rnd); |
157 | int (*constructor)(struct neighbour *); | 160 | int (*constructor)(struct neighbour *); |
158 | int (*pconstructor)(struct pneigh_entry *); | 161 | int (*pconstructor)(struct pneigh_entry *); |
159 | void (*pdestructor)(struct pneigh_entry *); | 162 | void (*pdestructor)(struct pneigh_entry *); |
@@ -172,12 +175,18 @@ struct neigh_table { | |||
172 | atomic_t entries; | 175 | atomic_t entries; |
173 | rwlock_t lock; | 176 | rwlock_t lock; |
174 | unsigned long last_rand; | 177 | unsigned long last_rand; |
175 | struct kmem_cache *kmem_cachep; | ||
176 | struct neigh_statistics __percpu *stats; | 178 | struct neigh_statistics __percpu *stats; |
177 | struct neigh_hash_table __rcu *nht; | 179 | struct neigh_hash_table __rcu *nht; |
178 | struct pneigh_entry **phash_buckets; | 180 | struct pneigh_entry **phash_buckets; |
179 | }; | 181 | }; |
180 | 182 | ||
183 | #define NEIGH_PRIV_ALIGN sizeof(long long) | ||
184 | |||
185 | static inline void *neighbour_priv(const struct neighbour *n) | ||
186 | { | ||
187 | return (char *)n + ALIGN(sizeof(*n) + n->tbl->key_len, NEIGH_PRIV_ALIGN); | ||
188 | } | ||
189 | |||
181 | /* flags for neigh_update() */ | 190 | /* flags for neigh_update() */ |
182 | #define NEIGH_UPDATE_F_OVERRIDE 0x00000001 | 191 | #define NEIGH_UPDATE_F_OVERRIDE 0x00000001 |
183 | #define NEIGH_UPDATE_F_WEAK_OVERRIDE 0x00000002 | 192 | #define NEIGH_UPDATE_F_WEAK_OVERRIDE 0x00000002 |
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 3bb6fa0eace0..ee547c149810 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
@@ -77,7 +77,7 @@ struct net { | |||
77 | struct netns_packet packet; | 77 | struct netns_packet packet; |
78 | struct netns_unix unx; | 78 | struct netns_unix unx; |
79 | struct netns_ipv4 ipv4; | 79 | struct netns_ipv4 ipv4; |
80 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 80 | #if IS_ENABLED(CONFIG_IPV6) |
81 | struct netns_ipv6 ipv6; | 81 | struct netns_ipv6 ipv6; |
82 | #endif | 82 | #endif |
83 | #if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE) | 83 | #if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE) |
diff --git a/include/net/netfilter/nf_conntrack_acct.h b/include/net/netfilter/nf_conntrack_acct.h index 4e9c63a20db2..463ae8e16696 100644 --- a/include/net/netfilter/nf_conntrack_acct.h +++ b/include/net/netfilter/nf_conntrack_acct.h | |||
@@ -15,8 +15,8 @@ | |||
15 | #include <net/netfilter/nf_conntrack_extend.h> | 15 | #include <net/netfilter/nf_conntrack_extend.h> |
16 | 16 | ||
17 | struct nf_conn_counter { | 17 | struct nf_conn_counter { |
18 | u_int64_t packets; | 18 | atomic64_t packets; |
19 | u_int64_t bytes; | 19 | atomic64_t bytes; |
20 | }; | 20 | }; |
21 | 21 | ||
22 | static inline | 22 | static inline |
diff --git a/include/net/netfilter/nf_conntrack_ecache.h b/include/net/netfilter/nf_conntrack_ecache.h index 4283508b3e18..a88fb6939387 100644 --- a/include/net/netfilter/nf_conntrack_ecache.h +++ b/include/net/netfilter/nf_conntrack_ecache.h | |||
@@ -67,18 +67,18 @@ struct nf_ct_event_notifier { | |||
67 | int (*fcn)(unsigned int events, struct nf_ct_event *item); | 67 | int (*fcn)(unsigned int events, struct nf_ct_event *item); |
68 | }; | 68 | }; |
69 | 69 | ||
70 | extern struct nf_ct_event_notifier __rcu *nf_conntrack_event_cb; | 70 | extern int nf_conntrack_register_notifier(struct net *net, struct nf_ct_event_notifier *nb); |
71 | extern int nf_conntrack_register_notifier(struct nf_ct_event_notifier *nb); | 71 | extern void nf_conntrack_unregister_notifier(struct net *net, struct nf_ct_event_notifier *nb); |
72 | extern void nf_conntrack_unregister_notifier(struct nf_ct_event_notifier *nb); | ||
73 | 72 | ||
74 | extern void nf_ct_deliver_cached_events(struct nf_conn *ct); | 73 | extern void nf_ct_deliver_cached_events(struct nf_conn *ct); |
75 | 74 | ||
76 | static inline void | 75 | static inline void |
77 | nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct) | 76 | nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct) |
78 | { | 77 | { |
78 | struct net *net = nf_ct_net(ct); | ||
79 | struct nf_conntrack_ecache *e; | 79 | struct nf_conntrack_ecache *e; |
80 | 80 | ||
81 | if (nf_conntrack_event_cb == NULL) | 81 | if (net->ct.nf_conntrack_event_cb == NULL) |
82 | return; | 82 | return; |
83 | 83 | ||
84 | e = nf_ct_ecache_find(ct); | 84 | e = nf_ct_ecache_find(ct); |
@@ -95,11 +95,12 @@ nf_conntrack_eventmask_report(unsigned int eventmask, | |||
95 | int report) | 95 | int report) |
96 | { | 96 | { |
97 | int ret = 0; | 97 | int ret = 0; |
98 | struct net *net = nf_ct_net(ct); | ||
98 | struct nf_ct_event_notifier *notify; | 99 | struct nf_ct_event_notifier *notify; |
99 | struct nf_conntrack_ecache *e; | 100 | struct nf_conntrack_ecache *e; |
100 | 101 | ||
101 | rcu_read_lock(); | 102 | rcu_read_lock(); |
102 | notify = rcu_dereference(nf_conntrack_event_cb); | 103 | notify = rcu_dereference(net->ct.nf_conntrack_event_cb); |
103 | if (notify == NULL) | 104 | if (notify == NULL) |
104 | goto out_unlock; | 105 | goto out_unlock; |
105 | 106 | ||
@@ -164,9 +165,8 @@ struct nf_exp_event_notifier { | |||
164 | int (*fcn)(unsigned int events, struct nf_exp_event *item); | 165 | int (*fcn)(unsigned int events, struct nf_exp_event *item); |
165 | }; | 166 | }; |
166 | 167 | ||
167 | extern struct nf_exp_event_notifier __rcu *nf_expect_event_cb; | 168 | extern int nf_ct_expect_register_notifier(struct net *net, struct nf_exp_event_notifier *nb); |
168 | extern int nf_ct_expect_register_notifier(struct nf_exp_event_notifier *nb); | 169 | extern void nf_ct_expect_unregister_notifier(struct net *net, struct nf_exp_event_notifier *nb); |
169 | extern void nf_ct_expect_unregister_notifier(struct nf_exp_event_notifier *nb); | ||
170 | 170 | ||
171 | static inline void | 171 | static inline void |
172 | nf_ct_expect_event_report(enum ip_conntrack_expect_events event, | 172 | nf_ct_expect_event_report(enum ip_conntrack_expect_events event, |
@@ -174,11 +174,12 @@ nf_ct_expect_event_report(enum ip_conntrack_expect_events event, | |||
174 | u32 pid, | 174 | u32 pid, |
175 | int report) | 175 | int report) |
176 | { | 176 | { |
177 | struct net *net = nf_ct_exp_net(exp); | ||
177 | struct nf_exp_event_notifier *notify; | 178 | struct nf_exp_event_notifier *notify; |
178 | struct nf_conntrack_ecache *e; | 179 | struct nf_conntrack_ecache *e; |
179 | 180 | ||
180 | rcu_read_lock(); | 181 | rcu_read_lock(); |
181 | notify = rcu_dereference(nf_expect_event_cb); | 182 | notify = rcu_dereference(net->ct.nf_expect_event_cb); |
182 | if (notify == NULL) | 183 | if (notify == NULL) |
183 | goto out_unlock; | 184 | goto out_unlock; |
184 | 185 | ||
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h index 0f8a8c587532..4619caadd9d1 100644 --- a/include/net/netfilter/nf_conntrack_expect.h +++ b/include/net/netfilter/nf_conntrack_expect.h | |||
@@ -91,7 +91,6 @@ static inline void nf_ct_unlink_expect(struct nf_conntrack_expect *exp) | |||
91 | 91 | ||
92 | void nf_ct_remove_expectations(struct nf_conn *ct); | 92 | void nf_ct_remove_expectations(struct nf_conn *ct); |
93 | void nf_ct_unexpect_related(struct nf_conntrack_expect *exp); | 93 | void nf_ct_unexpect_related(struct nf_conntrack_expect *exp); |
94 | void nf_ct_remove_userspace_expectations(void); | ||
95 | 94 | ||
96 | /* Allocate space for an expectation: this is mandatory before calling | 95 | /* Allocate space for an expectation: this is mandatory before calling |
97 | nf_ct_expect_related. You will have to call put afterwards. */ | 96 | nf_ct_expect_related. You will have to call put afterwards. */ |
diff --git a/include/net/netfilter/nf_conntrack_tuple.h b/include/net/netfilter/nf_conntrack_tuple.h index 2f8fb77bfdd1..aea3f8221be0 100644 --- a/include/net/netfilter/nf_conntrack_tuple.h +++ b/include/net/netfilter/nf_conntrack_tuple.h | |||
@@ -12,7 +12,6 @@ | |||
12 | 12 | ||
13 | #include <linux/netfilter/x_tables.h> | 13 | #include <linux/netfilter/x_tables.h> |
14 | #include <linux/netfilter/nf_conntrack_tuple_common.h> | 14 | #include <linux/netfilter/nf_conntrack_tuple_common.h> |
15 | #include <linux/netfilter_ipv4/nf_nat.h> | ||
16 | #include <linux/list_nulls.h> | 15 | #include <linux/list_nulls.h> |
17 | 16 | ||
18 | /* A `tuple' is a structure containing the information to uniquely | 17 | /* A `tuple' is a structure containing the information to uniquely |
diff --git a/include/net/netfilter/nf_nat.h b/include/net/netfilter/nf_nat.h index b8872df7285f..b4de990b55f1 100644 --- a/include/net/netfilter/nf_nat.h +++ b/include/net/netfilter/nf_nat.h | |||
@@ -1,14 +1,12 @@ | |||
1 | #ifndef _NF_NAT_H | 1 | #ifndef _NF_NAT_H |
2 | #define _NF_NAT_H | 2 | #define _NF_NAT_H |
3 | #include <linux/netfilter_ipv4.h> | 3 | #include <linux/netfilter_ipv4.h> |
4 | #include <linux/netfilter_ipv4/nf_nat.h> | 4 | #include <linux/netfilter/nf_nat.h> |
5 | #include <net/netfilter/nf_conntrack_tuple.h> | 5 | #include <net/netfilter/nf_conntrack_tuple.h> |
6 | 6 | ||
7 | #define NF_NAT_MAPPING_TYPE_MAX_NAMELEN 16 | ||
8 | |||
9 | enum nf_nat_manip_type { | 7 | enum nf_nat_manip_type { |
10 | IP_NAT_MANIP_SRC, | 8 | NF_NAT_MANIP_SRC, |
11 | IP_NAT_MANIP_DST | 9 | NF_NAT_MANIP_DST |
12 | }; | 10 | }; |
13 | 11 | ||
14 | /* SRC manip occurs POST_ROUTING or LOCAL_IN */ | 12 | /* SRC manip occurs POST_ROUTING or LOCAL_IN */ |
@@ -52,7 +50,7 @@ struct nf_conn_nat { | |||
52 | 50 | ||
53 | /* Set up the info structure to map into this range. */ | 51 | /* Set up the info structure to map into this range. */ |
54 | extern unsigned int nf_nat_setup_info(struct nf_conn *ct, | 52 | extern unsigned int nf_nat_setup_info(struct nf_conn *ct, |
55 | const struct nf_nat_range *range, | 53 | const struct nf_nat_ipv4_range *range, |
56 | enum nf_nat_manip_type maniptype); | 54 | enum nf_nat_manip_type maniptype); |
57 | 55 | ||
58 | /* Is this tuple already taken? (not by us)*/ | 56 | /* Is this tuple already taken? (not by us)*/ |
diff --git a/include/net/netfilter/nf_nat_core.h b/include/net/netfilter/nf_nat_core.h index 3dc7b98effeb..b13d8d18d595 100644 --- a/include/net/netfilter/nf_nat_core.h +++ b/include/net/netfilter/nf_nat_core.h | |||
@@ -20,7 +20,7 @@ extern int nf_nat_icmp_reply_translation(struct nf_conn *ct, | |||
20 | static inline int nf_nat_initialized(struct nf_conn *ct, | 20 | static inline int nf_nat_initialized(struct nf_conn *ct, |
21 | enum nf_nat_manip_type manip) | 21 | enum nf_nat_manip_type manip) |
22 | { | 22 | { |
23 | if (manip == IP_NAT_MANIP_SRC) | 23 | if (manip == NF_NAT_MANIP_SRC) |
24 | return ct->status & IPS_SRC_NAT_DONE; | 24 | return ct->status & IPS_SRC_NAT_DONE; |
25 | else | 25 | else |
26 | return ct->status & IPS_DST_NAT_DONE; | 26 | return ct->status & IPS_DST_NAT_DONE; |
diff --git a/include/net/netfilter/nf_nat_protocol.h b/include/net/netfilter/nf_nat_protocol.h index 93cc90d28e66..7b0b51165f70 100644 --- a/include/net/netfilter/nf_nat_protocol.h +++ b/include/net/netfilter/nf_nat_protocol.h | |||
@@ -4,14 +4,12 @@ | |||
4 | #include <net/netfilter/nf_nat.h> | 4 | #include <net/netfilter/nf_nat.h> |
5 | #include <linux/netfilter/nfnetlink_conntrack.h> | 5 | #include <linux/netfilter/nfnetlink_conntrack.h> |
6 | 6 | ||
7 | struct nf_nat_range; | 7 | struct nf_nat_ipv4_range; |
8 | 8 | ||
9 | struct nf_nat_protocol { | 9 | struct nf_nat_protocol { |
10 | /* Protocol number. */ | 10 | /* Protocol number. */ |
11 | unsigned int protonum; | 11 | unsigned int protonum; |
12 | 12 | ||
13 | struct module *me; | ||
14 | |||
15 | /* Translate a packet to the target according to manip type. | 13 | /* Translate a packet to the target according to manip type. |
16 | Return true if succeeded. */ | 14 | Return true if succeeded. */ |
17 | bool (*manip_pkt)(struct sk_buff *skb, | 15 | bool (*manip_pkt)(struct sk_buff *skb, |
@@ -30,15 +28,12 @@ struct nf_nat_protocol { | |||
30 | possible. Per-protocol part of tuple is initialized to the | 28 | possible. Per-protocol part of tuple is initialized to the |
31 | incoming packet. */ | 29 | incoming packet. */ |
32 | void (*unique_tuple)(struct nf_conntrack_tuple *tuple, | 30 | void (*unique_tuple)(struct nf_conntrack_tuple *tuple, |
33 | const struct nf_nat_range *range, | 31 | const struct nf_nat_ipv4_range *range, |
34 | enum nf_nat_manip_type maniptype, | 32 | enum nf_nat_manip_type maniptype, |
35 | const struct nf_conn *ct); | 33 | const struct nf_conn *ct); |
36 | 34 | ||
37 | int (*range_to_nlattr)(struct sk_buff *skb, | ||
38 | const struct nf_nat_range *range); | ||
39 | |||
40 | int (*nlattr_to_range)(struct nlattr *tb[], | 35 | int (*nlattr_to_range)(struct nlattr *tb[], |
41 | struct nf_nat_range *range); | 36 | struct nf_nat_ipv4_range *range); |
42 | }; | 37 | }; |
43 | 38 | ||
44 | /* Protocol registration. */ | 39 | /* Protocol registration. */ |
@@ -61,14 +56,12 @@ extern bool nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple, | |||
61 | const union nf_conntrack_man_proto *max); | 56 | const union nf_conntrack_man_proto *max); |
62 | 57 | ||
63 | extern void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, | 58 | extern void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, |
64 | const struct nf_nat_range *range, | 59 | const struct nf_nat_ipv4_range *range, |
65 | enum nf_nat_manip_type maniptype, | 60 | enum nf_nat_manip_type maniptype, |
66 | const struct nf_conn *ct, | 61 | const struct nf_conn *ct, |
67 | u_int16_t *rover); | 62 | u_int16_t *rover); |
68 | 63 | ||
69 | extern int nf_nat_proto_range_to_nlattr(struct sk_buff *skb, | ||
70 | const struct nf_nat_range *range); | ||
71 | extern int nf_nat_proto_nlattr_to_range(struct nlattr *tb[], | 64 | extern int nf_nat_proto_nlattr_to_range(struct nlattr *tb[], |
72 | struct nf_nat_range *range); | 65 | struct nf_nat_ipv4_range *range); |
73 | 66 | ||
74 | #endif /*_NF_NAT_PROTO_H*/ | 67 | #endif /*_NF_NAT_PROTO_H*/ |
diff --git a/include/net/netfilter/nf_tproxy_core.h b/include/net/netfilter/nf_tproxy_core.h index e505358d8999..75ca9291cf2c 100644 --- a/include/net/netfilter/nf_tproxy_core.h +++ b/include/net/netfilter/nf_tproxy_core.h | |||
@@ -131,7 +131,7 @@ nf_tproxy_get_sock_v4(struct net *net, const u8 protocol, | |||
131 | return sk; | 131 | return sk; |
132 | } | 132 | } |
133 | 133 | ||
134 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 134 | #if IS_ENABLED(CONFIG_IPV6) |
135 | static inline struct sock * | 135 | static inline struct sock * |
136 | nf_tproxy_get_sock_v6(struct net *net, const u8 protocol, | 136 | nf_tproxy_get_sock_v6(struct net *net, const u8 protocol, |
137 | const struct in6_addr *saddr, const struct in6_addr *daddr, | 137 | const struct in6_addr *saddr, const struct in6_addr *daddr, |
diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h index 0249399e51a7..7a911eca0f18 100644 --- a/include/net/netns/conntrack.h +++ b/include/net/netns/conntrack.h | |||
@@ -18,6 +18,8 @@ struct netns_ct { | |||
18 | struct hlist_nulls_head unconfirmed; | 18 | struct hlist_nulls_head unconfirmed; |
19 | struct hlist_nulls_head dying; | 19 | struct hlist_nulls_head dying; |
20 | struct ip_conntrack_stat __percpu *stat; | 20 | struct ip_conntrack_stat __percpu *stat; |
21 | struct nf_ct_event_notifier __rcu *nf_conntrack_event_cb; | ||
22 | struct nf_exp_event_notifier __rcu *nf_expect_event_cb; | ||
21 | int sysctl_events; | 23 | int sysctl_events; |
22 | unsigned int sysctl_events_retry_timeout; | 24 | unsigned int sysctl_events_retry_timeout; |
23 | int sysctl_acct; | 25 | int sysctl_acct; |
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h index d786b4fc02a4..bbd023a1c9b9 100644 --- a/include/net/netns/ipv4.h +++ b/include/net/netns/ipv4.h | |||
@@ -55,6 +55,7 @@ struct netns_ipv4 { | |||
55 | int current_rt_cache_rebuild_count; | 55 | int current_rt_cache_rebuild_count; |
56 | 56 | ||
57 | unsigned int sysctl_ping_group_range[2]; | 57 | unsigned int sysctl_ping_group_range[2]; |
58 | long sysctl_tcp_mem[3]; | ||
58 | 59 | ||
59 | atomic_t rt_genid; | 60 | atomic_t rt_genid; |
60 | atomic_t dev_addr_genid; | 61 | atomic_t dev_addr_genid; |
diff --git a/include/net/netns/mib.h b/include/net/netns/mib.h index 0b44112e2366..d542a4b28cca 100644 --- a/include/net/netns/mib.h +++ b/include/net/netns/mib.h | |||
@@ -10,15 +10,15 @@ struct netns_mib { | |||
10 | DEFINE_SNMP_STAT(struct udp_mib, udp_statistics); | 10 | DEFINE_SNMP_STAT(struct udp_mib, udp_statistics); |
11 | DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics); | 11 | DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics); |
12 | DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics); | 12 | DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics); |
13 | DEFINE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics); | 13 | DEFINE_SNMP_STAT_ATOMIC(struct icmpmsg_mib, icmpmsg_statistics); |
14 | 14 | ||
15 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 15 | #if IS_ENABLED(CONFIG_IPV6) |
16 | struct proc_dir_entry *proc_net_devsnmp6; | 16 | struct proc_dir_entry *proc_net_devsnmp6; |
17 | DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6); | 17 | DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6); |
18 | DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6); | 18 | DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6); |
19 | DEFINE_SNMP_STAT(struct ipstats_mib, ipv6_statistics); | 19 | DEFINE_SNMP_STAT(struct ipstats_mib, ipv6_statistics); |
20 | DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics); | 20 | DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics); |
21 | DEFINE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics); | 21 | DEFINE_SNMP_STAT_ATOMIC(struct icmpv6msg_mib, icmpv6msg_statistics); |
22 | #endif | 22 | #endif |
23 | #ifdef CONFIG_XFRM_STATISTICS | 23 | #ifdef CONFIG_XFRM_STATISTICS |
24 | DEFINE_SNMP_STAT(struct linux_xfrm_mib, xfrm_statistics); | 24 | DEFINE_SNMP_STAT(struct linux_xfrm_mib, xfrm_statistics); |
diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h index 748f91f87cd5..5299e69a32af 100644 --- a/include/net/netns/xfrm.h +++ b/include/net/netns/xfrm.h | |||
@@ -56,7 +56,7 @@ struct netns_xfrm { | |||
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | struct dst_ops xfrm4_dst_ops; | 58 | struct dst_ops xfrm4_dst_ops; |
59 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 59 | #if IS_ENABLED(CONFIG_IPV6) |
60 | struct dst_ops xfrm6_dst_ops; | 60 | struct dst_ops xfrm6_dst_ops; |
61 | #endif | 61 | #endif |
62 | }; | 62 | }; |
diff --git a/include/net/netprio_cgroup.h b/include/net/netprio_cgroup.h new file mode 100644 index 000000000000..e503b87c4c1b --- /dev/null +++ b/include/net/netprio_cgroup.h | |||
@@ -0,0 +1,57 @@ | |||
1 | /* | ||
2 | * netprio_cgroup.h Control Group Priority set | ||
3 | * | ||
4 | * | ||
5 | * Authors: Neil Horman <nhorman@tuxdriver.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the Free | ||
9 | * Software Foundation; either version 2 of the License, or (at your option) | ||
10 | * any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #ifndef _NETPRIO_CGROUP_H | ||
15 | #define _NETPRIO_CGROUP_H | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/cgroup.h> | ||
18 | #include <linux/hardirq.h> | ||
19 | #include <linux/rcupdate.h> | ||
20 | |||
21 | |||
22 | struct netprio_map { | ||
23 | struct rcu_head rcu; | ||
24 | u32 priomap_len; | ||
25 | u32 priomap[]; | ||
26 | }; | ||
27 | |||
28 | #ifdef CONFIG_CGROUPS | ||
29 | |||
30 | struct cgroup_netprio_state { | ||
31 | struct cgroup_subsys_state css; | ||
32 | u32 prioidx; | ||
33 | }; | ||
34 | |||
35 | #ifndef CONFIG_NETPRIO_CGROUP | ||
36 | extern int net_prio_subsys_id; | ||
37 | #endif | ||
38 | |||
39 | extern void sock_update_netprioidx(struct sock *sk); | ||
40 | |||
41 | static inline struct cgroup_netprio_state | ||
42 | *task_netprio_state(struct task_struct *p) | ||
43 | { | ||
44 | #if IS_ENABLED(CONFIG_NETPRIO_CGROUP) | ||
45 | return container_of(task_subsys_state(p, net_prio_subsys_id), | ||
46 | struct cgroup_netprio_state, css); | ||
47 | #else | ||
48 | return NULL; | ||
49 | #endif | ||
50 | } | ||
51 | |||
52 | #else | ||
53 | |||
54 | #define sock_update_netprioidx(sk) | ||
55 | #endif | ||
56 | |||
57 | #endif /* _NET_CLS_CGROUP_H */ | ||
diff --git a/include/net/protocol.h b/include/net/protocol.h index 6f7eb800974a..875f4895b033 100644 --- a/include/net/protocol.h +++ b/include/net/protocol.h | |||
@@ -25,7 +25,7 @@ | |||
25 | #define _PROTOCOL_H | 25 | #define _PROTOCOL_H |
26 | 26 | ||
27 | #include <linux/in6.h> | 27 | #include <linux/in6.h> |
28 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 28 | #if IS_ENABLED(CONFIG_IPV6) |
29 | #include <linux/ipv6.h> | 29 | #include <linux/ipv6.h> |
30 | #endif | 30 | #endif |
31 | 31 | ||
@@ -38,7 +38,7 @@ struct net_protocol { | |||
38 | void (*err_handler)(struct sk_buff *skb, u32 info); | 38 | void (*err_handler)(struct sk_buff *skb, u32 info); |
39 | int (*gso_send_check)(struct sk_buff *skb); | 39 | int (*gso_send_check)(struct sk_buff *skb); |
40 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, | 40 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, |
41 | u32 features); | 41 | netdev_features_t features); |
42 | struct sk_buff **(*gro_receive)(struct sk_buff **head, | 42 | struct sk_buff **(*gro_receive)(struct sk_buff **head, |
43 | struct sk_buff *skb); | 43 | struct sk_buff *skb); |
44 | int (*gro_complete)(struct sk_buff *skb); | 44 | int (*gro_complete)(struct sk_buff *skb); |
@@ -46,7 +46,7 @@ struct net_protocol { | |||
46 | netns_ok:1; | 46 | netns_ok:1; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 49 | #if IS_ENABLED(CONFIG_IPV6) |
50 | struct inet6_protocol { | 50 | struct inet6_protocol { |
51 | int (*handler)(struct sk_buff *skb); | 51 | int (*handler)(struct sk_buff *skb); |
52 | 52 | ||
@@ -57,7 +57,7 @@ struct inet6_protocol { | |||
57 | 57 | ||
58 | int (*gso_send_check)(struct sk_buff *skb); | 58 | int (*gso_send_check)(struct sk_buff *skb); |
59 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, | 59 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, |
60 | u32 features); | 60 | netdev_features_t features); |
61 | struct sk_buff **(*gro_receive)(struct sk_buff **head, | 61 | struct sk_buff **(*gro_receive)(struct sk_buff **head, |
62 | struct sk_buff *skb); | 62 | struct sk_buff *skb); |
63 | int (*gro_complete)(struct sk_buff *skb); | 63 | int (*gro_complete)(struct sk_buff *skb); |
@@ -91,7 +91,7 @@ struct inet_protosw { | |||
91 | 91 | ||
92 | extern const struct net_protocol __rcu *inet_protos[MAX_INET_PROTOS]; | 92 | extern const struct net_protocol __rcu *inet_protos[MAX_INET_PROTOS]; |
93 | 93 | ||
94 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 94 | #if IS_ENABLED(CONFIG_IPV6) |
95 | extern const struct inet6_protocol __rcu *inet6_protos[MAX_INET_PROTOS]; | 95 | extern const struct inet6_protocol __rcu *inet6_protos[MAX_INET_PROTOS]; |
96 | #endif | 96 | #endif |
97 | 97 | ||
@@ -100,7 +100,7 @@ extern int inet_del_protocol(const struct net_protocol *prot, unsigned char num) | |||
100 | extern void inet_register_protosw(struct inet_protosw *p); | 100 | extern void inet_register_protosw(struct inet_protosw *p); |
101 | extern void inet_unregister_protosw(struct inet_protosw *p); | 101 | extern void inet_unregister_protosw(struct inet_protosw *p); |
102 | 102 | ||
103 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 103 | #if IS_ENABLED(CONFIG_IPV6) |
104 | extern int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char num); | 104 | extern int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char num); |
105 | extern int inet6_del_protocol(const struct inet6_protocol *prot, unsigned char num); | 105 | extern int inet6_del_protocol(const struct inet6_protocol *prot, unsigned char num); |
106 | extern int inet6_register_protosw(struct inet_protosw *p); | 106 | extern int inet6_register_protosw(struct inet_protosw *p); |
diff --git a/include/net/red.h b/include/net/red.h index 3319f16b3beb..ef715a16cce4 100644 --- a/include/net/red.h +++ b/include/net/red.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <net/pkt_sched.h> | 5 | #include <net/pkt_sched.h> |
6 | #include <net/inet_ecn.h> | 6 | #include <net/inet_ecn.h> |
7 | #include <net/dsfield.h> | 7 | #include <net/dsfield.h> |
8 | #include <linux/reciprocal_div.h> | ||
8 | 9 | ||
9 | /* Random Early Detection (RED) algorithm. | 10 | /* Random Early Detection (RED) algorithm. |
10 | ======================================= | 11 | ======================================= |
@@ -87,6 +88,29 @@ | |||
87 | etc. | 88 | etc. |
88 | */ | 89 | */ |
89 | 90 | ||
91 | /* | ||
92 | * Adaptative RED : An Algorithm for Increasing the Robustness of RED's AQM | ||
93 | * (Sally FLoyd, Ramakrishna Gummadi, and Scott Shenker) August 2001 | ||
94 | * | ||
95 | * Every 500 ms: | ||
96 | * if (avg > target and max_p <= 0.5) | ||
97 | * increase max_p : max_p += alpha; | ||
98 | * else if (avg < target and max_p >= 0.01) | ||
99 | * decrease max_p : max_p *= beta; | ||
100 | * | ||
101 | * target :[qth_min + 0.4*(qth_min - qth_max), | ||
102 | * qth_min + 0.6*(qth_min - qth_max)]. | ||
103 | * alpha : min(0.01, max_p / 4) | ||
104 | * beta : 0.9 | ||
105 | * max_P is a Q0.32 fixed point number (with 32 bits mantissa) | ||
106 | * max_P between 0.01 and 0.5 (1% - 50%) [ Its no longer a negative power of two ] | ||
107 | */ | ||
108 | #define RED_ONE_PERCENT ((u32)DIV_ROUND_CLOSEST(1ULL<<32, 100)) | ||
109 | |||
110 | #define MAX_P_MIN (1 * RED_ONE_PERCENT) | ||
111 | #define MAX_P_MAX (50 * RED_ONE_PERCENT) | ||
112 | #define MAX_P_ALPHA(val) min(MAX_P_MIN, val / 4) | ||
113 | |||
90 | #define RED_STAB_SIZE 256 | 114 | #define RED_STAB_SIZE 256 |
91 | #define RED_STAB_MASK (RED_STAB_SIZE - 1) | 115 | #define RED_STAB_MASK (RED_STAB_SIZE - 1) |
92 | 116 | ||
@@ -101,10 +125,14 @@ struct red_stats { | |||
101 | 125 | ||
102 | struct red_parms { | 126 | struct red_parms { |
103 | /* Parameters */ | 127 | /* Parameters */ |
104 | u32 qth_min; /* Min avg length threshold: A scaled */ | 128 | u32 qth_min; /* Min avg length threshold: Wlog scaled */ |
105 | u32 qth_max; /* Max avg length threshold: A scaled */ | 129 | u32 qth_max; /* Max avg length threshold: Wlog scaled */ |
106 | u32 Scell_max; | 130 | u32 Scell_max; |
107 | u32 Rmask; /* Cached random mask, see red_rmask */ | 131 | u32 max_P; /* probability, [0 .. 1.0] 32 scaled */ |
132 | u32 max_P_reciprocal; /* reciprocal_value(max_P / qth_delta) */ | ||
133 | u32 qth_delta; /* max_th - min_th */ | ||
134 | u32 target_min; /* min_th + 0.4*(max_th - min_th) */ | ||
135 | u32 target_max; /* min_th + 0.6*(max_th - min_th) */ | ||
108 | u8 Scell_log; | 136 | u8 Scell_log; |
109 | u8 Wlog; /* log(W) */ | 137 | u8 Wlog; /* log(W) */ |
110 | u8 Plog; /* random number bits */ | 138 | u8 Plog; /* random number bits */ |
@@ -115,19 +143,23 @@ struct red_parms { | |||
115 | number generation */ | 143 | number generation */ |
116 | u32 qR; /* Cached random number */ | 144 | u32 qR; /* Cached random number */ |
117 | 145 | ||
118 | unsigned long qavg; /* Average queue length: A scaled */ | 146 | unsigned long qavg; /* Average queue length: Wlog scaled */ |
119 | psched_time_t qidlestart; /* Start of current idle period */ | 147 | ktime_t qidlestart; /* Start of current idle period */ |
120 | }; | 148 | }; |
121 | 149 | ||
122 | static inline u32 red_rmask(u8 Plog) | 150 | static inline u32 red_maxp(u8 Plog) |
123 | { | 151 | { |
124 | return Plog < 32 ? ((1 << Plog) - 1) : ~0UL; | 152 | return Plog < 32 ? (~0U >> Plog) : ~0U; |
125 | } | 153 | } |
126 | 154 | ||
155 | |||
127 | static inline void red_set_parms(struct red_parms *p, | 156 | static inline void red_set_parms(struct red_parms *p, |
128 | u32 qth_min, u32 qth_max, u8 Wlog, u8 Plog, | 157 | u32 qth_min, u32 qth_max, u8 Wlog, u8 Plog, |
129 | u8 Scell_log, u8 *stab) | 158 | u8 Scell_log, u8 *stab, u32 max_P) |
130 | { | 159 | { |
160 | int delta = qth_max - qth_min; | ||
161 | u32 max_p_delta; | ||
162 | |||
131 | /* Reset average queue length, the value is strictly bound | 163 | /* Reset average queue length, the value is strictly bound |
132 | * to the parameters below, reseting hurts a bit but leaving | 164 | * to the parameters below, reseting hurts a bit but leaving |
133 | * it might result in an unreasonable qavg for a while. --TGR | 165 | * it might result in an unreasonable qavg for a while. --TGR |
@@ -139,26 +171,45 @@ static inline void red_set_parms(struct red_parms *p, | |||
139 | p->qth_max = qth_max << Wlog; | 171 | p->qth_max = qth_max << Wlog; |
140 | p->Wlog = Wlog; | 172 | p->Wlog = Wlog; |
141 | p->Plog = Plog; | 173 | p->Plog = Plog; |
142 | p->Rmask = red_rmask(Plog); | 174 | if (delta < 0) |
175 | delta = 1; | ||
176 | p->qth_delta = delta; | ||
177 | if (!max_P) { | ||
178 | max_P = red_maxp(Plog); | ||
179 | max_P *= delta; /* max_P = (qth_max - qth_min)/2^Plog */ | ||
180 | } | ||
181 | p->max_P = max_P; | ||
182 | max_p_delta = max_P / delta; | ||
183 | max_p_delta = max(max_p_delta, 1U); | ||
184 | p->max_P_reciprocal = reciprocal_value(max_p_delta); | ||
185 | |||
186 | /* RED Adaptative target : | ||
187 | * [min_th + 0.4*(min_th - max_th), | ||
188 | * min_th + 0.6*(min_th - max_th)]. | ||
189 | */ | ||
190 | delta /= 5; | ||
191 | p->target_min = qth_min + 2*delta; | ||
192 | p->target_max = qth_min + 3*delta; | ||
193 | |||
143 | p->Scell_log = Scell_log; | 194 | p->Scell_log = Scell_log; |
144 | p->Scell_max = (255 << Scell_log); | 195 | p->Scell_max = (255 << Scell_log); |
145 | 196 | ||
146 | memcpy(p->Stab, stab, sizeof(p->Stab)); | 197 | memcpy(p->Stab, stab, sizeof(p->Stab)); |
147 | } | 198 | } |
148 | 199 | ||
149 | static inline int red_is_idling(struct red_parms *p) | 200 | static inline int red_is_idling(const struct red_parms *p) |
150 | { | 201 | { |
151 | return p->qidlestart != PSCHED_PASTPERFECT; | 202 | return p->qidlestart.tv64 != 0; |
152 | } | 203 | } |
153 | 204 | ||
154 | static inline void red_start_of_idle_period(struct red_parms *p) | 205 | static inline void red_start_of_idle_period(struct red_parms *p) |
155 | { | 206 | { |
156 | p->qidlestart = psched_get_time(); | 207 | p->qidlestart = ktime_get(); |
157 | } | 208 | } |
158 | 209 | ||
159 | static inline void red_end_of_idle_period(struct red_parms *p) | 210 | static inline void red_end_of_idle_period(struct red_parms *p) |
160 | { | 211 | { |
161 | p->qidlestart = PSCHED_PASTPERFECT; | 212 | p->qidlestart.tv64 = 0; |
162 | } | 213 | } |
163 | 214 | ||
164 | static inline void red_restart(struct red_parms *p) | 215 | static inline void red_restart(struct red_parms *p) |
@@ -168,15 +219,12 @@ static inline void red_restart(struct red_parms *p) | |||
168 | p->qcount = -1; | 219 | p->qcount = -1; |
169 | } | 220 | } |
170 | 221 | ||
171 | static inline unsigned long red_calc_qavg_from_idle_time(struct red_parms *p) | 222 | static inline unsigned long red_calc_qavg_from_idle_time(const struct red_parms *p) |
172 | { | 223 | { |
173 | psched_time_t now; | 224 | s64 delta = ktime_us_delta(ktime_get(), p->qidlestart); |
174 | long us_idle; | 225 | long us_idle = min_t(s64, delta, p->Scell_max); |
175 | int shift; | 226 | int shift; |
176 | 227 | ||
177 | now = psched_get_time(); | ||
178 | us_idle = psched_tdiff_bounded(now, p->qidlestart, p->Scell_max); | ||
179 | |||
180 | /* | 228 | /* |
181 | * The problem: ideally, average length queue recalcultion should | 229 | * The problem: ideally, average length queue recalcultion should |
182 | * be done over constant clock intervals. This is too expensive, so | 230 | * be done over constant clock intervals. This is too expensive, so |
@@ -218,7 +266,7 @@ static inline unsigned long red_calc_qavg_from_idle_time(struct red_parms *p) | |||
218 | } | 266 | } |
219 | } | 267 | } |
220 | 268 | ||
221 | static inline unsigned long red_calc_qavg_no_idle_time(struct red_parms *p, | 269 | static inline unsigned long red_calc_qavg_no_idle_time(const struct red_parms *p, |
222 | unsigned int backlog) | 270 | unsigned int backlog) |
223 | { | 271 | { |
224 | /* | 272 | /* |
@@ -233,7 +281,7 @@ static inline unsigned long red_calc_qavg_no_idle_time(struct red_parms *p, | |||
233 | return p->qavg + (backlog - (p->qavg >> p->Wlog)); | 281 | return p->qavg + (backlog - (p->qavg >> p->Wlog)); |
234 | } | 282 | } |
235 | 283 | ||
236 | static inline unsigned long red_calc_qavg(struct red_parms *p, | 284 | static inline unsigned long red_calc_qavg(const struct red_parms *p, |
237 | unsigned int backlog) | 285 | unsigned int backlog) |
238 | { | 286 | { |
239 | if (!red_is_idling(p)) | 287 | if (!red_is_idling(p)) |
@@ -242,23 +290,24 @@ static inline unsigned long red_calc_qavg(struct red_parms *p, | |||
242 | return red_calc_qavg_from_idle_time(p); | 290 | return red_calc_qavg_from_idle_time(p); |
243 | } | 291 | } |
244 | 292 | ||
245 | static inline u32 red_random(struct red_parms *p) | 293 | |
294 | static inline u32 red_random(const struct red_parms *p) | ||
246 | { | 295 | { |
247 | return net_random() & p->Rmask; | 296 | return reciprocal_divide(net_random(), p->max_P_reciprocal); |
248 | } | 297 | } |
249 | 298 | ||
250 | static inline int red_mark_probability(struct red_parms *p, unsigned long qavg) | 299 | static inline int red_mark_probability(const struct red_parms *p, unsigned long qavg) |
251 | { | 300 | { |
252 | /* The formula used below causes questions. | 301 | /* The formula used below causes questions. |
253 | 302 | ||
254 | OK. qR is random number in the interval 0..Rmask | 303 | OK. qR is random number in the interval |
304 | (0..1/max_P)*(qth_max-qth_min) | ||
255 | i.e. 0..(2^Plog). If we used floating point | 305 | i.e. 0..(2^Plog). If we used floating point |
256 | arithmetics, it would be: (2^Plog)*rnd_num, | 306 | arithmetics, it would be: (2^Plog)*rnd_num, |
257 | where rnd_num is less 1. | 307 | where rnd_num is less 1. |
258 | 308 | ||
259 | Taking into account, that qavg have fixed | 309 | Taking into account, that qavg have fixed |
260 | point at Wlog, and Plog is related to max_P by | 310 | point at Wlog, two lines |
261 | max_P = (qth_max-qth_min)/2^Plog; two lines | ||
262 | below have the following floating point equivalent: | 311 | below have the following floating point equivalent: |
263 | 312 | ||
264 | max_P*(qavg - qth_min)/(qth_max-qth_min) < rnd/qcount | 313 | max_P*(qavg - qth_min)/(qth_max-qth_min) < rnd/qcount |
@@ -318,4 +367,25 @@ static inline int red_action(struct red_parms *p, unsigned long qavg) | |||
318 | return RED_DONT_MARK; | 367 | return RED_DONT_MARK; |
319 | } | 368 | } |
320 | 369 | ||
370 | static inline void red_adaptative_algo(struct red_parms *p) | ||
371 | { | ||
372 | unsigned long qavg; | ||
373 | u32 max_p_delta; | ||
374 | |||
375 | qavg = p->qavg; | ||
376 | if (red_is_idling(p)) | ||
377 | qavg = red_calc_qavg_from_idle_time(p); | ||
378 | |||
379 | /* p->qavg is fixed point number with point at Wlog */ | ||
380 | qavg >>= p->Wlog; | ||
381 | |||
382 | if (qavg > p->target_max && p->max_P <= MAX_P_MAX) | ||
383 | p->max_P += MAX_P_ALPHA(p->max_P); /* maxp = maxp + alpha */ | ||
384 | else if (qavg < p->target_min && p->max_P >= MAX_P_MIN) | ||
385 | p->max_P = (p->max_P/10)*9; /* maxp = maxp * Beta */ | ||
386 | |||
387 | max_p_delta = DIV_ROUND_CLOSEST(p->max_P, p->qth_delta); | ||
388 | max_p_delta = max(max_p_delta, 1U); | ||
389 | p->max_P_reciprocal = reciprocal_value(max_p_delta); | ||
390 | } | ||
321 | #endif | 391 | #endif |
diff --git a/include/net/route.h b/include/net/route.h index db7b3432f07c..91855d185b53 100644 --- a/include/net/route.h +++ b/include/net/route.h | |||
@@ -71,12 +71,12 @@ struct rtable { | |||
71 | struct fib_info *fi; /* for client ref to shared metrics */ | 71 | struct fib_info *fi; /* for client ref to shared metrics */ |
72 | }; | 72 | }; |
73 | 73 | ||
74 | static inline bool rt_is_input_route(struct rtable *rt) | 74 | static inline bool rt_is_input_route(const struct rtable *rt) |
75 | { | 75 | { |
76 | return rt->rt_route_iif != 0; | 76 | return rt->rt_route_iif != 0; |
77 | } | 77 | } |
78 | 78 | ||
79 | static inline bool rt_is_output_route(struct rtable *rt) | 79 | static inline bool rt_is_output_route(const struct rtable *rt) |
80 | { | 80 | { |
81 | return rt->rt_route_iif == 0; | 81 | return rt->rt_route_iif == 0; |
82 | } | 82 | } |
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h index 6a72a58cde59..d3685615a8b0 100644 --- a/include/net/sctp/sctp.h +++ b/include/net/sctp/sctp.h | |||
@@ -71,7 +71,7 @@ | |||
71 | #include <linux/jiffies.h> | 71 | #include <linux/jiffies.h> |
72 | #include <linux/idr.h> | 72 | #include <linux/idr.h> |
73 | 73 | ||
74 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 74 | #if IS_ENABLED(CONFIG_IPV6) |
75 | #include <net/ipv6.h> | 75 | #include <net/ipv6.h> |
76 | #include <net/ip6_route.h> | 76 | #include <net/ip6_route.h> |
77 | #endif | 77 | #endif |
@@ -383,7 +383,7 @@ static inline void sctp_sysctl_unregister(void) { return; } | |||
383 | /* Size of Supported Address Parameter for 'x' address types. */ | 383 | /* Size of Supported Address Parameter for 'x' address types. */ |
384 | #define SCTP_SAT_LEN(x) (sizeof(struct sctp_paramhdr) + (x) * sizeof(__u16)) | 384 | #define SCTP_SAT_LEN(x) (sizeof(struct sctp_paramhdr) + (x) * sizeof(__u16)) |
385 | 385 | ||
386 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 386 | #if IS_ENABLED(CONFIG_IPV6) |
387 | 387 | ||
388 | void sctp_v6_pf_init(void); | 388 | void sctp_v6_pf_init(void); |
389 | void sctp_v6_pf_exit(void); | 389 | void sctp_v6_pf_exit(void); |
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index e90e7a9935dd..88949a994538 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h | |||
@@ -235,12 +235,15 @@ extern struct sctp_globals { | |||
235 | 235 | ||
236 | /* Flag to indicate whether computing and verifying checksum | 236 | /* Flag to indicate whether computing and verifying checksum |
237 | * is disabled. */ | 237 | * is disabled. */ |
238 | int checksum_disable; | 238 | bool checksum_disable; |
239 | 239 | ||
240 | /* Threshold for rwnd update SACKS. Receive buffer shifted this many | 240 | /* Threshold for rwnd update SACKS. Receive buffer shifted this many |
241 | * bits is an indicator of when to send and window update SACK. | 241 | * bits is an indicator of when to send and window update SACK. |
242 | */ | 242 | */ |
243 | int rwnd_update_shift; | 243 | int rwnd_update_shift; |
244 | |||
245 | /* Threshold for autoclose timeout, in seconds. */ | ||
246 | unsigned long max_autoclose; | ||
244 | } sctp_globals; | 247 | } sctp_globals; |
245 | 248 | ||
246 | #define sctp_rto_initial (sctp_globals.rto_initial) | 249 | #define sctp_rto_initial (sctp_globals.rto_initial) |
@@ -281,6 +284,7 @@ extern struct sctp_globals { | |||
281 | #define sctp_auth_enable (sctp_globals.auth_enable) | 284 | #define sctp_auth_enable (sctp_globals.auth_enable) |
282 | #define sctp_checksum_disable (sctp_globals.checksum_disable) | 285 | #define sctp_checksum_disable (sctp_globals.checksum_disable) |
283 | #define sctp_rwnd_upd_shift (sctp_globals.rwnd_update_shift) | 286 | #define sctp_rwnd_upd_shift (sctp_globals.rwnd_update_shift) |
287 | #define sctp_max_autoclose (sctp_globals.max_autoclose) | ||
284 | 288 | ||
285 | /* SCTP Socket type: UDP or TCP style. */ | 289 | /* SCTP Socket type: UDP or TCP style. */ |
286 | typedef enum { | 290 | typedef enum { |
@@ -365,7 +369,7 @@ static inline struct sock *sctp_opt2sk(const struct sctp_sock *sp) | |||
365 | return (struct sock *)sp; | 369 | return (struct sock *)sp; |
366 | } | 370 | } |
367 | 371 | ||
368 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 372 | #if IS_ENABLED(CONFIG_IPV6) |
369 | struct sctp6_sock { | 373 | struct sctp6_sock { |
370 | struct sctp_sock sctp; | 374 | struct sctp_sock sctp; |
371 | struct ipv6_pinfo inet6; | 375 | struct ipv6_pinfo inet6; |
@@ -1085,6 +1089,7 @@ void sctp_transport_burst_reset(struct sctp_transport *); | |||
1085 | unsigned long sctp_transport_timeout(struct sctp_transport *); | 1089 | unsigned long sctp_transport_timeout(struct sctp_transport *); |
1086 | void sctp_transport_reset(struct sctp_transport *); | 1090 | void sctp_transport_reset(struct sctp_transport *); |
1087 | void sctp_transport_update_pmtu(struct sctp_transport *, u32); | 1091 | void sctp_transport_update_pmtu(struct sctp_transport *, u32); |
1092 | void sctp_transport_immediate_rtx(struct sctp_transport *); | ||
1088 | 1093 | ||
1089 | 1094 | ||
1090 | /* This is the structure we use to queue packets as they come into | 1095 | /* This is the structure we use to queue packets as they come into |
diff --git a/include/net/snmp.h b/include/net/snmp.h index 8f0f9ac0307f..2f65e1686fc8 100644 --- a/include/net/snmp.h +++ b/include/net/snmp.h | |||
@@ -67,7 +67,7 @@ struct icmp_mib { | |||
67 | 67 | ||
68 | #define ICMPMSG_MIB_MAX __ICMPMSG_MIB_MAX | 68 | #define ICMPMSG_MIB_MAX __ICMPMSG_MIB_MAX |
69 | struct icmpmsg_mib { | 69 | struct icmpmsg_mib { |
70 | unsigned long mibs[ICMPMSG_MIB_MAX]; | 70 | atomic_long_t mibs[ICMPMSG_MIB_MAX]; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | /* ICMP6 (IPv6-ICMP) */ | 73 | /* ICMP6 (IPv6-ICMP) */ |
@@ -84,7 +84,7 @@ struct icmpv6_mib_device { | |||
84 | #define ICMP6MSG_MIB_MAX __ICMP6MSG_MIB_MAX | 84 | #define ICMP6MSG_MIB_MAX __ICMP6MSG_MIB_MAX |
85 | /* per network ns counters */ | 85 | /* per network ns counters */ |
86 | struct icmpv6msg_mib { | 86 | struct icmpv6msg_mib { |
87 | unsigned long mibs[ICMP6MSG_MIB_MAX]; | 87 | atomic_long_t mibs[ICMP6MSG_MIB_MAX]; |
88 | }; | 88 | }; |
89 | /* per device counters, (shared on all cpus) */ | 89 | /* per device counters, (shared on all cpus) */ |
90 | struct icmpv6msg_mib_device { | 90 | struct icmpv6msg_mib_device { |
diff --git a/include/net/sock.h b/include/net/sock.h index c0c32a4cdd07..bb972d254dff 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -53,6 +53,8 @@ | |||
53 | #include <linux/security.h> | 53 | #include <linux/security.h> |
54 | #include <linux/slab.h> | 54 | #include <linux/slab.h> |
55 | #include <linux/uaccess.h> | 55 | #include <linux/uaccess.h> |
56 | #include <linux/memcontrol.h> | ||
57 | #include <linux/res_counter.h> | ||
56 | 58 | ||
57 | #include <linux/filter.h> | 59 | #include <linux/filter.h> |
58 | #include <linux/rculist_nulls.h> | 60 | #include <linux/rculist_nulls.h> |
@@ -62,6 +64,22 @@ | |||
62 | #include <net/dst.h> | 64 | #include <net/dst.h> |
63 | #include <net/checksum.h> | 65 | #include <net/checksum.h> |
64 | 66 | ||
67 | struct cgroup; | ||
68 | struct cgroup_subsys; | ||
69 | #ifdef CONFIG_NET | ||
70 | int mem_cgroup_sockets_init(struct cgroup *cgrp, struct cgroup_subsys *ss); | ||
71 | void mem_cgroup_sockets_destroy(struct cgroup *cgrp, struct cgroup_subsys *ss); | ||
72 | #else | ||
73 | static inline | ||
74 | int mem_cgroup_sockets_init(struct cgroup *cgrp, struct cgroup_subsys *ss) | ||
75 | { | ||
76 | return 0; | ||
77 | } | ||
78 | static inline | ||
79 | void mem_cgroup_sockets_destroy(struct cgroup *cgrp, struct cgroup_subsys *ss) | ||
80 | { | ||
81 | } | ||
82 | #endif | ||
65 | /* | 83 | /* |
66 | * This structure really needs to be cleaned up. | 84 | * This structure really needs to be cleaned up. |
67 | * Most of it is for TCP, and not used by any of | 85 | * Most of it is for TCP, and not used by any of |
@@ -167,6 +185,7 @@ struct sock_common { | |||
167 | /* public: */ | 185 | /* public: */ |
168 | }; | 186 | }; |
169 | 187 | ||
188 | struct cg_proto; | ||
170 | /** | 189 | /** |
171 | * struct sock - network layer representation of sockets | 190 | * struct sock - network layer representation of sockets |
172 | * @__sk_common: shared layout with inet_timewait_sock | 191 | * @__sk_common: shared layout with inet_timewait_sock |
@@ -227,6 +246,7 @@ struct sock_common { | |||
227 | * @sk_security: used by security modules | 246 | * @sk_security: used by security modules |
228 | * @sk_mark: generic packet mark | 247 | * @sk_mark: generic packet mark |
229 | * @sk_classid: this socket's cgroup classid | 248 | * @sk_classid: this socket's cgroup classid |
249 | * @sk_cgrp: this socket's cgroup-specific proto data | ||
230 | * @sk_write_pending: a write to stream socket waits to start | 250 | * @sk_write_pending: a write to stream socket waits to start |
231 | * @sk_state_change: callback to indicate change in the state of the sock | 251 | * @sk_state_change: callback to indicate change in the state of the sock |
232 | * @sk_data_ready: callback to indicate there is data to be processed | 252 | * @sk_data_ready: callback to indicate there is data to be processed |
@@ -306,8 +326,8 @@ struct sock { | |||
306 | kmemcheck_bitfield_end(flags); | 326 | kmemcheck_bitfield_end(flags); |
307 | int sk_wmem_queued; | 327 | int sk_wmem_queued; |
308 | gfp_t sk_allocation; | 328 | gfp_t sk_allocation; |
309 | int sk_route_caps; | 329 | netdev_features_t sk_route_caps; |
310 | int sk_route_nocaps; | 330 | netdev_features_t sk_route_nocaps; |
311 | int sk_gso_type; | 331 | int sk_gso_type; |
312 | unsigned int sk_gso_max_size; | 332 | unsigned int sk_gso_max_size; |
313 | int sk_rcvlowat; | 333 | int sk_rcvlowat; |
@@ -320,6 +340,9 @@ struct sock { | |||
320 | unsigned short sk_ack_backlog; | 340 | unsigned short sk_ack_backlog; |
321 | unsigned short sk_max_ack_backlog; | 341 | unsigned short sk_max_ack_backlog; |
322 | __u32 sk_priority; | 342 | __u32 sk_priority; |
343 | #ifdef CONFIG_CGROUPS | ||
344 | __u32 sk_cgrp_prioidx; | ||
345 | #endif | ||
323 | struct pid *sk_peer_pid; | 346 | struct pid *sk_peer_pid; |
324 | const struct cred *sk_peer_cred; | 347 | const struct cred *sk_peer_cred; |
325 | long sk_rcvtimeo; | 348 | long sk_rcvtimeo; |
@@ -338,6 +361,7 @@ struct sock { | |||
338 | #endif | 361 | #endif |
339 | __u32 sk_mark; | 362 | __u32 sk_mark; |
340 | u32 sk_classid; | 363 | u32 sk_classid; |
364 | struct cg_proto *sk_cgrp; | ||
341 | void (*sk_state_change)(struct sock *sk); | 365 | void (*sk_state_change)(struct sock *sk); |
342 | void (*sk_data_ready)(struct sock *sk, int bytes); | 366 | void (*sk_data_ready)(struct sock *sk, int bytes); |
343 | void (*sk_write_space)(struct sock *sk); | 367 | void (*sk_write_space)(struct sock *sk); |
@@ -638,12 +662,14 @@ static inline void __sk_add_backlog(struct sock *sk, struct sk_buff *skb) | |||
638 | 662 | ||
639 | /* | 663 | /* |
640 | * Take into account size of receive queue and backlog queue | 664 | * Take into account size of receive queue and backlog queue |
665 | * Do not take into account this skb truesize, | ||
666 | * to allow even a single big packet to come. | ||
641 | */ | 667 | */ |
642 | static inline bool sk_rcvqueues_full(const struct sock *sk, const struct sk_buff *skb) | 668 | static inline bool sk_rcvqueues_full(const struct sock *sk, const struct sk_buff *skb) |
643 | { | 669 | { |
644 | unsigned int qsize = sk->sk_backlog.len + atomic_read(&sk->sk_rmem_alloc); | 670 | unsigned int qsize = sk->sk_backlog.len + atomic_read(&sk->sk_rmem_alloc); |
645 | 671 | ||
646 | return qsize + skb->truesize > sk->sk_rcvbuf; | 672 | return qsize > sk->sk_rcvbuf; |
647 | } | 673 | } |
648 | 674 | ||
649 | /* The per-socket spinlock must be held here. */ | 675 | /* The per-socket spinlock must be held here. */ |
@@ -834,6 +860,37 @@ struct proto { | |||
834 | #ifdef SOCK_REFCNT_DEBUG | 860 | #ifdef SOCK_REFCNT_DEBUG |
835 | atomic_t socks; | 861 | atomic_t socks; |
836 | #endif | 862 | #endif |
863 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM | ||
864 | /* | ||
865 | * cgroup specific init/deinit functions. Called once for all | ||
866 | * protocols that implement it, from cgroups populate function. | ||
867 | * This function has to setup any files the protocol want to | ||
868 | * appear in the kmem cgroup filesystem. | ||
869 | */ | ||
870 | int (*init_cgroup)(struct cgroup *cgrp, | ||
871 | struct cgroup_subsys *ss); | ||
872 | void (*destroy_cgroup)(struct cgroup *cgrp, | ||
873 | struct cgroup_subsys *ss); | ||
874 | struct cg_proto *(*proto_cgroup)(struct mem_cgroup *memcg); | ||
875 | #endif | ||
876 | }; | ||
877 | |||
878 | struct cg_proto { | ||
879 | void (*enter_memory_pressure)(struct sock *sk); | ||
880 | struct res_counter *memory_allocated; /* Current allocated memory. */ | ||
881 | struct percpu_counter *sockets_allocated; /* Current number of sockets. */ | ||
882 | int *memory_pressure; | ||
883 | long *sysctl_mem; | ||
884 | /* | ||
885 | * memcg field is used to find which memcg we belong directly | ||
886 | * Each memcg struct can hold more than one cg_proto, so container_of | ||
887 | * won't really cut. | ||
888 | * | ||
889 | * The elegant solution would be having an inverse function to | ||
890 | * proto_cgroup in struct proto, but that means polluting the structure | ||
891 | * for everybody, instead of just for memcg users. | ||
892 | */ | ||
893 | struct mem_cgroup *memcg; | ||
837 | }; | 894 | }; |
838 | 895 | ||
839 | extern int proto_register(struct proto *prot, int alloc_slab); | 896 | extern int proto_register(struct proto *prot, int alloc_slab); |
@@ -852,7 +909,7 @@ static inline void sk_refcnt_debug_dec(struct sock *sk) | |||
852 | sk->sk_prot->name, sk, atomic_read(&sk->sk_prot->socks)); | 909 | sk->sk_prot->name, sk, atomic_read(&sk->sk_prot->socks)); |
853 | } | 910 | } |
854 | 911 | ||
855 | static inline void sk_refcnt_debug_release(const struct sock *sk) | 912 | inline void sk_refcnt_debug_release(const struct sock *sk) |
856 | { | 913 | { |
857 | if (atomic_read(&sk->sk_refcnt) != 1) | 914 | if (atomic_read(&sk->sk_refcnt) != 1) |
858 | printk(KERN_DEBUG "Destruction of the %s socket %p delayed, refcnt=%d\n", | 915 | printk(KERN_DEBUG "Destruction of the %s socket %p delayed, refcnt=%d\n", |
@@ -864,6 +921,208 @@ static inline void sk_refcnt_debug_release(const struct sock *sk) | |||
864 | #define sk_refcnt_debug_release(sk) do { } while (0) | 921 | #define sk_refcnt_debug_release(sk) do { } while (0) |
865 | #endif /* SOCK_REFCNT_DEBUG */ | 922 | #endif /* SOCK_REFCNT_DEBUG */ |
866 | 923 | ||
924 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM | ||
925 | extern struct jump_label_key memcg_socket_limit_enabled; | ||
926 | static inline struct cg_proto *parent_cg_proto(struct proto *proto, | ||
927 | struct cg_proto *cg_proto) | ||
928 | { | ||
929 | return proto->proto_cgroup(parent_mem_cgroup(cg_proto->memcg)); | ||
930 | } | ||
931 | #define mem_cgroup_sockets_enabled static_branch(&memcg_socket_limit_enabled) | ||
932 | #else | ||
933 | #define mem_cgroup_sockets_enabled 0 | ||
934 | static inline struct cg_proto *parent_cg_proto(struct proto *proto, | ||
935 | struct cg_proto *cg_proto) | ||
936 | { | ||
937 | return NULL; | ||
938 | } | ||
939 | #endif | ||
940 | |||
941 | |||
942 | static inline bool sk_has_memory_pressure(const struct sock *sk) | ||
943 | { | ||
944 | return sk->sk_prot->memory_pressure != NULL; | ||
945 | } | ||
946 | |||
947 | static inline bool sk_under_memory_pressure(const struct sock *sk) | ||
948 | { | ||
949 | if (!sk->sk_prot->memory_pressure) | ||
950 | return false; | ||
951 | |||
952 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) | ||
953 | return !!*sk->sk_cgrp->memory_pressure; | ||
954 | |||
955 | return !!*sk->sk_prot->memory_pressure; | ||
956 | } | ||
957 | |||
958 | static inline void sk_leave_memory_pressure(struct sock *sk) | ||
959 | { | ||
960 | int *memory_pressure = sk->sk_prot->memory_pressure; | ||
961 | |||
962 | if (!memory_pressure) | ||
963 | return; | ||
964 | |||
965 | if (*memory_pressure) | ||
966 | *memory_pressure = 0; | ||
967 | |||
968 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) { | ||
969 | struct cg_proto *cg_proto = sk->sk_cgrp; | ||
970 | struct proto *prot = sk->sk_prot; | ||
971 | |||
972 | for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto)) | ||
973 | if (*cg_proto->memory_pressure) | ||
974 | *cg_proto->memory_pressure = 0; | ||
975 | } | ||
976 | |||
977 | } | ||
978 | |||
979 | static inline void sk_enter_memory_pressure(struct sock *sk) | ||
980 | { | ||
981 | if (!sk->sk_prot->enter_memory_pressure) | ||
982 | return; | ||
983 | |||
984 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) { | ||
985 | struct cg_proto *cg_proto = sk->sk_cgrp; | ||
986 | struct proto *prot = sk->sk_prot; | ||
987 | |||
988 | for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto)) | ||
989 | cg_proto->enter_memory_pressure(sk); | ||
990 | } | ||
991 | |||
992 | sk->sk_prot->enter_memory_pressure(sk); | ||
993 | } | ||
994 | |||
995 | static inline long sk_prot_mem_limits(const struct sock *sk, int index) | ||
996 | { | ||
997 | long *prot = sk->sk_prot->sysctl_mem; | ||
998 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) | ||
999 | prot = sk->sk_cgrp->sysctl_mem; | ||
1000 | return prot[index]; | ||
1001 | } | ||
1002 | |||
1003 | static inline void memcg_memory_allocated_add(struct cg_proto *prot, | ||
1004 | unsigned long amt, | ||
1005 | int *parent_status) | ||
1006 | { | ||
1007 | struct res_counter *fail; | ||
1008 | int ret; | ||
1009 | |||
1010 | ret = res_counter_charge(prot->memory_allocated, | ||
1011 | amt << PAGE_SHIFT, &fail); | ||
1012 | |||
1013 | if (ret < 0) | ||
1014 | *parent_status = OVER_LIMIT; | ||
1015 | } | ||
1016 | |||
1017 | static inline void memcg_memory_allocated_sub(struct cg_proto *prot, | ||
1018 | unsigned long amt) | ||
1019 | { | ||
1020 | res_counter_uncharge(prot->memory_allocated, amt << PAGE_SHIFT); | ||
1021 | } | ||
1022 | |||
1023 | static inline u64 memcg_memory_allocated_read(struct cg_proto *prot) | ||
1024 | { | ||
1025 | u64 ret; | ||
1026 | ret = res_counter_read_u64(prot->memory_allocated, RES_USAGE); | ||
1027 | return ret >> PAGE_SHIFT; | ||
1028 | } | ||
1029 | |||
1030 | static inline long | ||
1031 | sk_memory_allocated(const struct sock *sk) | ||
1032 | { | ||
1033 | struct proto *prot = sk->sk_prot; | ||
1034 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) | ||
1035 | return memcg_memory_allocated_read(sk->sk_cgrp); | ||
1036 | |||
1037 | return atomic_long_read(prot->memory_allocated); | ||
1038 | } | ||
1039 | |||
1040 | static inline long | ||
1041 | sk_memory_allocated_add(struct sock *sk, int amt, int *parent_status) | ||
1042 | { | ||
1043 | struct proto *prot = sk->sk_prot; | ||
1044 | |||
1045 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) { | ||
1046 | memcg_memory_allocated_add(sk->sk_cgrp, amt, parent_status); | ||
1047 | /* update the root cgroup regardless */ | ||
1048 | atomic_long_add_return(amt, prot->memory_allocated); | ||
1049 | return memcg_memory_allocated_read(sk->sk_cgrp); | ||
1050 | } | ||
1051 | |||
1052 | return atomic_long_add_return(amt, prot->memory_allocated); | ||
1053 | } | ||
1054 | |||
1055 | static inline void | ||
1056 | sk_memory_allocated_sub(struct sock *sk, int amt, int parent_status) | ||
1057 | { | ||
1058 | struct proto *prot = sk->sk_prot; | ||
1059 | |||
1060 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp && | ||
1061 | parent_status != OVER_LIMIT) /* Otherwise was uncharged already */ | ||
1062 | memcg_memory_allocated_sub(sk->sk_cgrp, amt); | ||
1063 | |||
1064 | atomic_long_sub(amt, prot->memory_allocated); | ||
1065 | } | ||
1066 | |||
1067 | static inline void sk_sockets_allocated_dec(struct sock *sk) | ||
1068 | { | ||
1069 | struct proto *prot = sk->sk_prot; | ||
1070 | |||
1071 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) { | ||
1072 | struct cg_proto *cg_proto = sk->sk_cgrp; | ||
1073 | |||
1074 | for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto)) | ||
1075 | percpu_counter_dec(cg_proto->sockets_allocated); | ||
1076 | } | ||
1077 | |||
1078 | percpu_counter_dec(prot->sockets_allocated); | ||
1079 | } | ||
1080 | |||
1081 | static inline void sk_sockets_allocated_inc(struct sock *sk) | ||
1082 | { | ||
1083 | struct proto *prot = sk->sk_prot; | ||
1084 | |||
1085 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) { | ||
1086 | struct cg_proto *cg_proto = sk->sk_cgrp; | ||
1087 | |||
1088 | for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto)) | ||
1089 | percpu_counter_inc(cg_proto->sockets_allocated); | ||
1090 | } | ||
1091 | |||
1092 | percpu_counter_inc(prot->sockets_allocated); | ||
1093 | } | ||
1094 | |||
1095 | static inline int | ||
1096 | sk_sockets_allocated_read_positive(struct sock *sk) | ||
1097 | { | ||
1098 | struct proto *prot = sk->sk_prot; | ||
1099 | |||
1100 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) | ||
1101 | return percpu_counter_sum_positive(sk->sk_cgrp->sockets_allocated); | ||
1102 | |||
1103 | return percpu_counter_sum_positive(prot->sockets_allocated); | ||
1104 | } | ||
1105 | |||
1106 | static inline int | ||
1107 | proto_sockets_allocated_sum_positive(struct proto *prot) | ||
1108 | { | ||
1109 | return percpu_counter_sum_positive(prot->sockets_allocated); | ||
1110 | } | ||
1111 | |||
1112 | static inline long | ||
1113 | proto_memory_allocated(struct proto *prot) | ||
1114 | { | ||
1115 | return atomic_long_read(prot->memory_allocated); | ||
1116 | } | ||
1117 | |||
1118 | static inline bool | ||
1119 | proto_memory_pressure(struct proto *prot) | ||
1120 | { | ||
1121 | if (!prot->memory_pressure) | ||
1122 | return false; | ||
1123 | return !!*prot->memory_pressure; | ||
1124 | } | ||
1125 | |||
867 | 1126 | ||
868 | #ifdef CONFIG_PROC_FS | 1127 | #ifdef CONFIG_PROC_FS |
869 | /* Called with local bh disabled */ | 1128 | /* Called with local bh disabled */ |
@@ -1090,8 +1349,8 @@ extern struct sock *sk_alloc(struct net *net, int family, | |||
1090 | struct proto *prot); | 1349 | struct proto *prot); |
1091 | extern void sk_free(struct sock *sk); | 1350 | extern void sk_free(struct sock *sk); |
1092 | extern void sk_release_kernel(struct sock *sk); | 1351 | extern void sk_release_kernel(struct sock *sk); |
1093 | extern struct sock *sk_clone(const struct sock *sk, | 1352 | extern struct sock *sk_clone_lock(const struct sock *sk, |
1094 | const gfp_t priority); | 1353 | const gfp_t priority); |
1095 | 1354 | ||
1096 | extern struct sk_buff *sock_wmalloc(struct sock *sk, | 1355 | extern struct sk_buff *sock_wmalloc(struct sock *sk, |
1097 | unsigned long size, int force, | 1356 | unsigned long size, int force, |
@@ -1394,7 +1653,7 @@ static inline int sk_can_gso(const struct sock *sk) | |||
1394 | 1653 | ||
1395 | extern void sk_setup_caps(struct sock *sk, struct dst_entry *dst); | 1654 | extern void sk_setup_caps(struct sock *sk, struct dst_entry *dst); |
1396 | 1655 | ||
1397 | static inline void sk_nocaps_add(struct sock *sk, int flags) | 1656 | static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags) |
1398 | { | 1657 | { |
1399 | sk->sk_route_nocaps |= flags; | 1658 | sk->sk_route_nocaps |= flags; |
1400 | sk->sk_route_caps &= ~flags; | 1659 | sk->sk_route_caps &= ~flags; |
@@ -1671,7 +1930,7 @@ static inline struct page *sk_stream_alloc_page(struct sock *sk) | |||
1671 | 1930 | ||
1672 | page = alloc_pages(sk->sk_allocation, 0); | 1931 | page = alloc_pages(sk->sk_allocation, 0); |
1673 | if (!page) { | 1932 | if (!page) { |
1674 | sk->sk_prot->enter_memory_pressure(sk); | 1933 | sk_enter_memory_pressure(sk); |
1675 | sk_stream_moderate_sndbuf(sk); | 1934 | sk_stream_moderate_sndbuf(sk); |
1676 | } | 1935 | } |
1677 | return page; | 1936 | return page; |
diff --git a/include/net/tcp.h b/include/net/tcp.h index bb18c4d69aba..0118ea999f67 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <net/dst.h> | 44 | #include <net/dst.h> |
45 | 45 | ||
46 | #include <linux/seq_file.h> | 46 | #include <linux/seq_file.h> |
47 | #include <linux/memcontrol.h> | ||
47 | 48 | ||
48 | extern struct inet_hashinfo tcp_hashinfo; | 49 | extern struct inet_hashinfo tcp_hashinfo; |
49 | 50 | ||
@@ -229,7 +230,6 @@ extern int sysctl_tcp_fack; | |||
229 | extern int sysctl_tcp_reordering; | 230 | extern int sysctl_tcp_reordering; |
230 | extern int sysctl_tcp_ecn; | 231 | extern int sysctl_tcp_ecn; |
231 | extern int sysctl_tcp_dsack; | 232 | extern int sysctl_tcp_dsack; |
232 | extern long sysctl_tcp_mem[3]; | ||
233 | extern int sysctl_tcp_wmem[3]; | 233 | extern int sysctl_tcp_wmem[3]; |
234 | extern int sysctl_tcp_rmem[3]; | 234 | extern int sysctl_tcp_rmem[3]; |
235 | extern int sysctl_tcp_app_win; | 235 | extern int sysctl_tcp_app_win; |
@@ -285,7 +285,7 @@ static inline bool tcp_too_many_orphans(struct sock *sk, int shift) | |||
285 | } | 285 | } |
286 | 286 | ||
287 | if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF && | 287 | if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF && |
288 | atomic_long_read(&tcp_memory_allocated) > sysctl_tcp_mem[2]) | 288 | sk_memory_allocated(sk) > sk_prot_mem_limits(sk, 2)) |
289 | return true; | 289 | return true; |
290 | return false; | 290 | return false; |
291 | } | 291 | } |
@@ -628,7 +628,7 @@ extern u32 __tcp_select_window(struct sock *sk); | |||
628 | struct tcp_skb_cb { | 628 | struct tcp_skb_cb { |
629 | union { | 629 | union { |
630 | struct inet_skb_parm h4; | 630 | struct inet_skb_parm h4; |
631 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 631 | #if IS_ENABLED(CONFIG_IPV6) |
632 | struct inet6_skb_parm h6; | 632 | struct inet6_skb_parm h6; |
633 | #endif | 633 | #endif |
634 | } header; /* For incoming frames */ | 634 | } header; /* For incoming frames */ |
@@ -773,12 +773,12 @@ static inline int tcp_is_reno(const struct tcp_sock *tp) | |||
773 | 773 | ||
774 | static inline int tcp_is_fack(const struct tcp_sock *tp) | 774 | static inline int tcp_is_fack(const struct tcp_sock *tp) |
775 | { | 775 | { |
776 | return tp->rx_opt.sack_ok & 2; | 776 | return tp->rx_opt.sack_ok & TCP_FACK_ENABLED; |
777 | } | 777 | } |
778 | 778 | ||
779 | static inline void tcp_enable_fack(struct tcp_sock *tp) | 779 | static inline void tcp_enable_fack(struct tcp_sock *tp) |
780 | { | 780 | { |
781 | tp->rx_opt.sack_ok |= 2; | 781 | tp->rx_opt.sack_ok |= TCP_FACK_ENABLED; |
782 | } | 782 | } |
783 | 783 | ||
784 | static inline unsigned int tcp_left_out(const struct tcp_sock *tp) | 784 | static inline unsigned int tcp_left_out(const struct tcp_sock *tp) |
@@ -834,6 +834,14 @@ static inline __u32 tcp_current_ssthresh(const struct sock *sk) | |||
834 | extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh); | 834 | extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh); |
835 | extern __u32 tcp_init_cwnd(const struct tcp_sock *tp, const struct dst_entry *dst); | 835 | extern __u32 tcp_init_cwnd(const struct tcp_sock *tp, const struct dst_entry *dst); |
836 | 836 | ||
837 | /* The maximum number of MSS of available cwnd for which TSO defers | ||
838 | * sending if not using sysctl_tcp_tso_win_divisor. | ||
839 | */ | ||
840 | static inline __u32 tcp_max_tso_deferred_mss(const struct tcp_sock *tp) | ||
841 | { | ||
842 | return 3; | ||
843 | } | ||
844 | |||
837 | /* Slow start with delack produces 3 packets of burst, so that | 845 | /* Slow start with delack produces 3 packets of burst, so that |
838 | * it is safe "de facto". This will be the default - same as | 846 | * it is safe "de facto". This will be the default - same as |
839 | * the default reordering threshold - but if reordering increases, | 847 | * the default reordering threshold - but if reordering increases, |
@@ -1144,7 +1152,7 @@ struct tcp6_md5sig_key { | |||
1144 | /* - sock block */ | 1152 | /* - sock block */ |
1145 | struct tcp_md5sig_info { | 1153 | struct tcp_md5sig_info { |
1146 | struct tcp4_md5sig_key *keys4; | 1154 | struct tcp4_md5sig_key *keys4; |
1147 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 1155 | #if IS_ENABLED(CONFIG_IPV6) |
1148 | struct tcp6_md5sig_key *keys6; | 1156 | struct tcp6_md5sig_key *keys6; |
1149 | u32 entries6; | 1157 | u32 entries6; |
1150 | u32 alloced6; | 1158 | u32 alloced6; |
@@ -1171,7 +1179,7 @@ struct tcp6_pseudohdr { | |||
1171 | 1179 | ||
1172 | union tcp_md5sum_block { | 1180 | union tcp_md5sum_block { |
1173 | struct tcp4_pseudohdr ip4; | 1181 | struct tcp4_pseudohdr ip4; |
1174 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 1182 | #if IS_ENABLED(CONFIG_IPV6) |
1175 | struct tcp6_pseudohdr ip6; | 1183 | struct tcp6_pseudohdr ip6; |
1176 | #endif | 1184 | #endif |
1177 | }; | 1185 | }; |
@@ -1430,7 +1438,8 @@ extern struct request_sock_ops tcp6_request_sock_ops; | |||
1430 | extern void tcp_v4_destroy_sock(struct sock *sk); | 1438 | extern void tcp_v4_destroy_sock(struct sock *sk); |
1431 | 1439 | ||
1432 | extern int tcp_v4_gso_send_check(struct sk_buff *skb); | 1440 | extern int tcp_v4_gso_send_check(struct sk_buff *skb); |
1433 | extern struct sk_buff *tcp_tso_segment(struct sk_buff *skb, u32 features); | 1441 | extern struct sk_buff *tcp_tso_segment(struct sk_buff *skb, |
1442 | netdev_features_t features); | ||
1434 | extern struct sk_buff **tcp_gro_receive(struct sk_buff **head, | 1443 | extern struct sk_buff **tcp_gro_receive(struct sk_buff **head, |
1435 | struct sk_buff *skb); | 1444 | struct sk_buff *skb); |
1436 | extern struct sk_buff **tcp4_gro_receive(struct sk_buff **head, | 1445 | extern struct sk_buff **tcp4_gro_receive(struct sk_buff **head, |
diff --git a/include/net/tcp_memcontrol.h b/include/net/tcp_memcontrol.h new file mode 100644 index 000000000000..3512082fa909 --- /dev/null +++ b/include/net/tcp_memcontrol.h | |||
@@ -0,0 +1,19 @@ | |||
1 | #ifndef _TCP_MEMCG_H | ||
2 | #define _TCP_MEMCG_H | ||
3 | |||
4 | struct tcp_memcontrol { | ||
5 | struct cg_proto cg_proto; | ||
6 | /* per-cgroup tcp memory pressure knobs */ | ||
7 | struct res_counter tcp_memory_allocated; | ||
8 | struct percpu_counter tcp_sockets_allocated; | ||
9 | /* those two are read-mostly, leave them at the end */ | ||
10 | long tcp_prot_mem[3]; | ||
11 | int tcp_memory_pressure; | ||
12 | }; | ||
13 | |||
14 | struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg); | ||
15 | int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss); | ||
16 | void tcp_destroy_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss); | ||
17 | unsigned long long tcp_max_memory(const struct mem_cgroup *memcg); | ||
18 | void tcp_prot_mem(struct mem_cgroup *memcg, long val, int idx); | ||
19 | #endif /* _TCP_MEMCG_H */ | ||
diff --git a/include/net/udp.h b/include/net/udp.h index 3b285f402f48..e39592f682c3 100644 --- a/include/net/udp.h +++ b/include/net/udp.h | |||
@@ -41,7 +41,7 @@ | |||
41 | struct udp_skb_cb { | 41 | struct udp_skb_cb { |
42 | union { | 42 | union { |
43 | struct inet_skb_parm h4; | 43 | struct inet_skb_parm h4; |
44 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 44 | #if IS_ENABLED(CONFIG_IPV6) |
45 | struct inet6_skb_parm h6; | 45 | struct inet6_skb_parm h6; |
46 | #endif | 46 | #endif |
47 | } header; | 47 | } header; |
@@ -194,9 +194,15 @@ extern int udp_lib_setsockopt(struct sock *sk, int level, int optname, | |||
194 | extern struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, | 194 | extern struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, |
195 | __be32 daddr, __be16 dport, | 195 | __be32 daddr, __be16 dport, |
196 | int dif); | 196 | int dif); |
197 | extern struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, | ||
198 | __be32 daddr, __be16 dport, | ||
199 | int dif, struct udp_table *tbl); | ||
197 | extern struct sock *udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be16 sport, | 200 | extern struct sock *udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be16 sport, |
198 | const struct in6_addr *daddr, __be16 dport, | 201 | const struct in6_addr *daddr, __be16 dport, |
199 | int dif); | 202 | int dif); |
203 | extern struct sock *__udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be16 sport, | ||
204 | const struct in6_addr *daddr, __be16 dport, | ||
205 | int dif, struct udp_table *tbl); | ||
200 | 206 | ||
201 | /* | 207 | /* |
202 | * SNMP statistics for UDP and UDP-Lite | 208 | * SNMP statistics for UDP and UDP-Lite |
@@ -217,7 +223,7 @@ extern struct sock *udp6_lib_lookup(struct net *net, const struct in6_addr *sadd | |||
217 | else SNMP_INC_STATS_USER((net)->mib.udp_stats_in6, field); \ | 223 | else SNMP_INC_STATS_USER((net)->mib.udp_stats_in6, field); \ |
218 | } while(0) | 224 | } while(0) |
219 | 225 | ||
220 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 226 | #if IS_ENABLED(CONFIG_IPV6) |
221 | #define UDPX_INC_STATS_BH(sk, field) \ | 227 | #define UDPX_INC_STATS_BH(sk, field) \ |
222 | do { \ | 228 | do { \ |
223 | if ((sk)->sk_family == AF_INET) \ | 229 | if ((sk)->sk_family == AF_INET) \ |
@@ -258,5 +264,6 @@ extern void udp4_proc_exit(void); | |||
258 | extern void udp_init(void); | 264 | extern void udp_init(void); |
259 | 265 | ||
260 | extern int udp4_ufo_send_check(struct sk_buff *skb); | 266 | extern int udp4_ufo_send_check(struct sk_buff *skb); |
261 | extern struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, u32 features); | 267 | extern struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, |
268 | netdev_features_t features); | ||
262 | #endif /* _UDP_H */ | 269 | #endif /* _UDP_H */ |
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index b203e14d26b7..89174e29dca9 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -827,6 +827,14 @@ static inline bool addr_match(const void *token1, const void *token2, | |||
827 | return true; | 827 | return true; |
828 | } | 828 | } |
829 | 829 | ||
830 | static inline bool addr4_match(__be32 a1, __be32 a2, u8 prefixlen) | ||
831 | { | ||
832 | /* C99 6.5.7 (3): u32 << 32 is undefined behaviour */ | ||
833 | if (prefixlen == 0) | ||
834 | return true; | ||
835 | return !((a1 ^ a2) & htonl(0xFFFFFFFFu << (32 - prefixlen))); | ||
836 | } | ||
837 | |||
830 | static __inline__ | 838 | static __inline__ |
831 | __be16 xfrm_flowi_sport(const struct flowi *fl, const union flowi_uli *uli) | 839 | __be16 xfrm_flowi_sport(const struct flowi *fl, const union flowi_uli *uli) |
832 | { | 840 | { |
@@ -1209,8 +1217,8 @@ void xfrm_flowi_addr_get(const struct flowi *fl, | |||
1209 | memcpy(&daddr->a4, &fl->u.ip4.daddr, sizeof(daddr->a4)); | 1217 | memcpy(&daddr->a4, &fl->u.ip4.daddr, sizeof(daddr->a4)); |
1210 | break; | 1218 | break; |
1211 | case AF_INET6: | 1219 | case AF_INET6: |
1212 | ipv6_addr_copy((struct in6_addr *)&saddr->a6, &fl->u.ip6.saddr); | 1220 | *(struct in6_addr *)saddr->a6 = fl->u.ip6.saddr; |
1213 | ipv6_addr_copy((struct in6_addr *)&daddr->a6, &fl->u.ip6.daddr); | 1221 | *(struct in6_addr *)daddr->a6 = fl->u.ip6.daddr; |
1214 | break; | 1222 | break; |
1215 | } | 1223 | } |
1216 | } | 1224 | } |