aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/af_inet.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/af_inet.c')
-rw-r--r--net/ipv4/af_inet.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index c8f7aee587d1..07a02f6e9696 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -157,6 +157,7 @@ void inet_sock_destruct(struct sock *sk)
157 157
158 kfree(rcu_dereference_protected(inet->inet_opt, 1)); 158 kfree(rcu_dereference_protected(inet->inet_opt, 1));
159 dst_release(rcu_dereference_check(sk->sk_dst_cache, 1)); 159 dst_release(rcu_dereference_check(sk->sk_dst_cache, 1));
160 dst_release(sk->sk_rx_dst);
160 sk_refcnt_debug_dec(sk); 161 sk_refcnt_debug_dec(sk);
161} 162}
162EXPORT_SYMBOL(inet_sock_destruct); 163EXPORT_SYMBOL(inet_sock_destruct);
@@ -242,20 +243,18 @@ void build_ehash_secret(void)
242} 243}
243EXPORT_SYMBOL(build_ehash_secret); 244EXPORT_SYMBOL(build_ehash_secret);
244 245
245static inline int inet_netns_ok(struct net *net, int protocol) 246static inline int inet_netns_ok(struct net *net, __u8 protocol)
246{ 247{
247 int hash;
248 const struct net_protocol *ipprot; 248 const struct net_protocol *ipprot;
249 249
250 if (net_eq(net, &init_net)) 250 if (net_eq(net, &init_net))
251 return 1; 251 return 1;
252 252
253 hash = protocol & (MAX_INET_PROTOS - 1); 253 ipprot = rcu_dereference(inet_protos[protocol]);
254 ipprot = rcu_dereference(inet_protos[hash]); 254 if (ipprot == NULL) {
255
256 if (ipprot == NULL)
257 /* raw IP is OK */ 255 /* raw IP is OK */
258 return 1; 256 return 1;
257 }
259 return ipprot->netns_ok; 258 return ipprot->netns_ok;
260} 259}
261 260
@@ -553,7 +552,7 @@ int inet_dgram_connect(struct socket *sock, struct sockaddr *uaddr,
553 552
554 if (!inet_sk(sk)->inet_num && inet_autobind(sk)) 553 if (!inet_sk(sk)->inet_num && inet_autobind(sk))
555 return -EAGAIN; 554 return -EAGAIN;
556 return sk->sk_prot->connect(sk, (struct sockaddr *)uaddr, addr_len); 555 return sk->sk_prot->connect(sk, uaddr, addr_len);
557} 556}
558EXPORT_SYMBOL(inet_dgram_connect); 557EXPORT_SYMBOL(inet_dgram_connect);
559 558
@@ -1216,8 +1215,8 @@ EXPORT_SYMBOL(inet_sk_rebuild_header);
1216 1215
1217static int inet_gso_send_check(struct sk_buff *skb) 1216static int inet_gso_send_check(struct sk_buff *skb)
1218{ 1217{
1219 const struct iphdr *iph;
1220 const struct net_protocol *ops; 1218 const struct net_protocol *ops;
1219 const struct iphdr *iph;
1221 int proto; 1220 int proto;
1222 int ihl; 1221 int ihl;
1223 int err = -EINVAL; 1222 int err = -EINVAL;
@@ -1236,7 +1235,7 @@ static int inet_gso_send_check(struct sk_buff *skb)
1236 __skb_pull(skb, ihl); 1235 __skb_pull(skb, ihl);
1237 skb_reset_transport_header(skb); 1236 skb_reset_transport_header(skb);
1238 iph = ip_hdr(skb); 1237 iph = ip_hdr(skb);
1239 proto = iph->protocol & (MAX_INET_PROTOS - 1); 1238 proto = iph->protocol;
1240 err = -EPROTONOSUPPORT; 1239 err = -EPROTONOSUPPORT;
1241 1240
1242 rcu_read_lock(); 1241 rcu_read_lock();
@@ -1253,8 +1252,8 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb,
1253 netdev_features_t features) 1252 netdev_features_t features)
1254{ 1253{
1255 struct sk_buff *segs = ERR_PTR(-EINVAL); 1254 struct sk_buff *segs = ERR_PTR(-EINVAL);
1256 struct iphdr *iph;
1257 const struct net_protocol *ops; 1255 const struct net_protocol *ops;
1256 struct iphdr *iph;
1258 int proto; 1257 int proto;
1259 int ihl; 1258 int ihl;
1260 int id; 1259 int id;
@@ -1286,7 +1285,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb,
1286 skb_reset_transport_header(skb); 1285 skb_reset_transport_header(skb);
1287 iph = ip_hdr(skb); 1286 iph = ip_hdr(skb);
1288 id = ntohs(iph->id); 1287 id = ntohs(iph->id);
1289 proto = iph->protocol & (MAX_INET_PROTOS - 1); 1288 proto = iph->protocol;
1290 segs = ERR_PTR(-EPROTONOSUPPORT); 1289 segs = ERR_PTR(-EPROTONOSUPPORT);
1291 1290
1292 rcu_read_lock(); 1291 rcu_read_lock();
@@ -1340,7 +1339,7 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head,
1340 goto out; 1339 goto out;
1341 } 1340 }
1342 1341
1343 proto = iph->protocol & (MAX_INET_PROTOS - 1); 1342 proto = iph->protocol;
1344 1343
1345 rcu_read_lock(); 1344 rcu_read_lock();
1346 ops = rcu_dereference(inet_protos[proto]); 1345 ops = rcu_dereference(inet_protos[proto]);
@@ -1398,11 +1397,11 @@ out:
1398 1397
1399static int inet_gro_complete(struct sk_buff *skb) 1398static int inet_gro_complete(struct sk_buff *skb)
1400{ 1399{
1401 const struct net_protocol *ops; 1400 __be16 newlen = htons(skb->len - skb_network_offset(skb));
1402 struct iphdr *iph = ip_hdr(skb); 1401 struct iphdr *iph = ip_hdr(skb);
1403 int proto = iph->protocol & (MAX_INET_PROTOS - 1); 1402 const struct net_protocol *ops;
1403 int proto = iph->protocol;
1404 int err = -ENOSYS; 1404 int err = -ENOSYS;
1405 __be16 newlen = htons(skb->len - skb_network_offset(skb));
1406 1405
1407 csum_replace2(&iph->check, iph->tot_len, newlen); 1406 csum_replace2(&iph->check, iph->tot_len, newlen);
1408 iph->tot_len = newlen; 1407 iph->tot_len = newlen;
@@ -1520,14 +1519,15 @@ static const struct net_protocol igmp_protocol = {
1520#endif 1519#endif
1521 1520
1522static const struct net_protocol tcp_protocol = { 1521static const struct net_protocol tcp_protocol = {
1523 .handler = tcp_v4_rcv, 1522 .early_demux = tcp_v4_early_demux,
1524 .err_handler = tcp_v4_err, 1523 .handler = tcp_v4_rcv,
1525 .gso_send_check = tcp_v4_gso_send_check, 1524 .err_handler = tcp_v4_err,
1526 .gso_segment = tcp_tso_segment, 1525 .gso_send_check = tcp_v4_gso_send_check,
1527 .gro_receive = tcp4_gro_receive, 1526 .gso_segment = tcp_tso_segment,
1528 .gro_complete = tcp4_gro_complete, 1527 .gro_receive = tcp4_gro_receive,
1529 .no_policy = 1, 1528 .gro_complete = tcp4_gro_complete,
1530 .netns_ok = 1, 1529 .no_policy = 1,
1530 .netns_ok = 1,
1531}; 1531};
1532 1532
1533static const struct net_protocol udp_protocol = { 1533static const struct net_protocol udp_protocol = {