Skip to content

Commit a9be224

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Fix checksumming regressions, from Tom Herbert. 2) Undo unintentional permissions changes for SCTP rto_alpha and rto_beta sysfs knobs, from Denial Borkmann. 3) VXLAN, like other IP tunnels, should advertize it's encapsulation size using dev->needed_headroom instead of dev->hard_header_len. From Cong Wang. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: net: sctp: fix permissions for rto_alpha and rto_beta knobs vxlan: Checksum fixes net: add skb_pop_rcv_encapsulation udp: call __skb_checksum_complete when doing full checksum net: Fix save software checksum complete net: Fix GSO constants to match NETIF flags udp: ipv4: do not waste time in __udp4_lib_mcast_demux_lookup vxlan: use dev->needed_headroom instead of dev->hard_header_len MAINTAINERS: update cxgb4 maintainer
2 parents dd1845a + b58537a commit a9be224

File tree

10 files changed

+96
-34
lines changed

10 files changed

+96
-34
lines changed

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2594,7 +2594,7 @@ S: Supported
25942594
F: drivers/infiniband/hw/cxgb3/
25952595

25962596
CXGB4 ETHERNET DRIVER (CXGB4)
2597-
M: Dimitris Michailidis <dm@chelsio.com>
2597+
M: Hariprasad S <hariprasad@chelsio.com>
25982598
25992599
W: http://www.chelsio.com
26002600
S: Supported

drivers/net/vxlan.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,15 +1156,7 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
11561156
if (!vs)
11571157
goto drop;
11581158

1159-
/* If the NIC driver gave us an encapsulated packet
1160-
* with the encapsulation mark, the device checksummed it
1161-
* for us. Otherwise force the upper layers to verify it.
1162-
*/
1163-
if ((skb->ip_summed != CHECKSUM_UNNECESSARY && skb->ip_summed != CHECKSUM_PARTIAL) ||
1164-
!skb->encapsulation)
1165-
skb->ip_summed = CHECKSUM_NONE;
1166-
1167-
skb->encapsulation = 0;
1159+
skb_pop_rcv_encapsulation(skb);
11681160

11691161
vs->rcv(vs, skb, vxh->vx_vni);
11701162
return 0;
@@ -1201,6 +1193,7 @@ static void vxlan_rcv(struct vxlan_sock *vs,
12011193
skb_reset_mac_header(skb);
12021194
skb_scrub_packet(skb, !net_eq(vxlan->net, dev_net(vxlan->dev)));
12031195
skb->protocol = eth_type_trans(skb, vxlan->dev);
1196+
skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
12041197

12051198
/* Ignore packet loops (and multicast echo) */
12061199
if (ether_addr_equal(eth_hdr(skb)->h_source, vxlan->dev->dev_addr))
@@ -2247,9 +2240,9 @@ static void vxlan_setup(struct net_device *dev)
22472240
eth_hw_addr_random(dev);
22482241
ether_setup(dev);
22492242
if (vxlan->default_dst.remote_ip.sa.sa_family == AF_INET6)
2250-
dev->hard_header_len = ETH_HLEN + VXLAN6_HEADROOM;
2243+
dev->needed_headroom = ETH_HLEN + VXLAN6_HEADROOM;
22512244
else
2252-
dev->hard_header_len = ETH_HLEN + VXLAN_HEADROOM;
2245+
dev->needed_headroom = ETH_HLEN + VXLAN_HEADROOM;
22532246

22542247
dev->netdev_ops = &vxlan_netdev_ops;
22552248
dev->destructor = free_netdev;
@@ -2646,8 +2639,7 @@ static int vxlan_newlink(struct net *net, struct net_device *dev,
26462639
if (!tb[IFLA_MTU])
26472640
dev->mtu = lowerdev->mtu - (use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM);
26482641

2649-
/* update header length based on lower device */
2650-
dev->hard_header_len = lowerdev->hard_header_len +
2642+
dev->needed_headroom = lowerdev->hard_header_len +
26512643
(use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM);
26522644
} else if (use_ipv6)
26532645
vxlan->flags |= VXLAN_F_IPV6;

include/linux/netdev_features.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ enum {
117117
#define NETIF_F_GSO_IPIP __NETIF_F(GSO_IPIP)
118118
#define NETIF_F_GSO_SIT __NETIF_F(GSO_SIT)
119119
#define NETIF_F_GSO_UDP_TUNNEL __NETIF_F(GSO_UDP_TUNNEL)
120+
#define NETIF_F_GSO_UDP_TUNNEL_CSUM __NETIF_F(GSO_UDP_TUNNEL_CSUM)
120121
#define NETIF_F_GSO_MPLS __NETIF_F(GSO_MPLS)
121122
#define NETIF_F_HW_VLAN_STAG_FILTER __NETIF_F(HW_VLAN_STAG_FILTER)
122123
#define NETIF_F_HW_VLAN_STAG_RX __NETIF_F(HW_VLAN_STAG_RX)

include/linux/netdevice.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3305,6 +3305,13 @@ static inline bool net_gso_ok(netdev_features_t features, int gso_type)
33053305
BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
33063306
BUILD_BUG_ON(SKB_GSO_TCPV6 != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
33073307
BUILD_BUG_ON(SKB_GSO_FCOE != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT));
3308+
BUILD_BUG_ON(SKB_GSO_GRE != (NETIF_F_GSO_GRE >> NETIF_F_GSO_SHIFT));
3309+
BUILD_BUG_ON(SKB_GSO_GRE_CSUM != (NETIF_F_GSO_GRE_CSUM >> NETIF_F_GSO_SHIFT));
3310+
BUILD_BUG_ON(SKB_GSO_IPIP != (NETIF_F_GSO_IPIP >> NETIF_F_GSO_SHIFT));
3311+
BUILD_BUG_ON(SKB_GSO_SIT != (NETIF_F_GSO_SIT >> NETIF_F_GSO_SHIFT));
3312+
BUILD_BUG_ON(SKB_GSO_UDP_TUNNEL != (NETIF_F_GSO_UDP_TUNNEL >> NETIF_F_GSO_SHIFT));
3313+
BUILD_BUG_ON(SKB_GSO_UDP_TUNNEL_CSUM != (NETIF_F_GSO_UDP_TUNNEL_CSUM >> NETIF_F_GSO_SHIFT));
3314+
BUILD_BUG_ON(SKB_GSO_MPLS != (NETIF_F_GSO_MPLS >> NETIF_F_GSO_SHIFT));
33083315

33093316
return (features & feature) == feature;
33103317
}

include/linux/skbuff.h

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,17 +338,18 @@ enum {
338338

339339
SKB_GSO_GRE = 1 << 6,
340340

341-
SKB_GSO_IPIP = 1 << 7,
341+
SKB_GSO_GRE_CSUM = 1 << 7,
342342

343-
SKB_GSO_SIT = 1 << 8,
343+
SKB_GSO_IPIP = 1 << 8,
344344

345-
SKB_GSO_UDP_TUNNEL = 1 << 9,
345+
SKB_GSO_SIT = 1 << 9,
346346

347-
SKB_GSO_MPLS = 1 << 10,
347+
SKB_GSO_UDP_TUNNEL = 1 << 10,
348348

349349
SKB_GSO_UDP_TUNNEL_CSUM = 1 << 11,
350350

351-
SKB_GSO_GRE_CSUM = 1 << 12,
351+
SKB_GSO_MPLS = 1 << 12,
352+
352353
};
353354

354355
#if BITS_PER_LONG > 32
@@ -1853,6 +1854,18 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
18531854
return pskb_may_pull(skb, skb_network_offset(skb) + len);
18541855
}
18551856

1857+
static inline void skb_pop_rcv_encapsulation(struct sk_buff *skb)
1858+
{
1859+
/* Only continue with checksum unnecessary if device indicated
1860+
* it is valid across encapsulation (skb->encapsulation was set).
1861+
*/
1862+
if (skb->ip_summed == CHECKSUM_UNNECESSARY && !skb->encapsulation)
1863+
skb->ip_summed = CHECKSUM_NONE;
1864+
1865+
skb->encapsulation = 0;
1866+
skb->csum_valid = 0;
1867+
}
1868+
18561869
/*
18571870
* CPUs often take a performance hit when accessing unaligned memory
18581871
* locations. The actual performance hit varies, it can be small if the

include/net/udp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ struct sk_buff;
111111
*/
112112
static inline __sum16 __udp_lib_checksum_complete(struct sk_buff *skb)
113113
{
114-
return __skb_checksum_complete_head(skb, UDP_SKB_CB(skb)->cscov);
114+
return (UDP_SKB_CB(skb)->cscov == skb->len ?
115+
__skb_checksum_complete(skb) :
116+
__skb_checksum_complete_head(skb, UDP_SKB_CB(skb)->cscov));
115117
}
116118

117119
static inline int udp_lib_checksum_complete(struct sk_buff *skb)

net/core/datagram.c

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -739,22 +739,38 @@ __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len)
739739
__sum16 sum;
740740

741741
sum = csum_fold(skb_checksum(skb, 0, len, skb->csum));
742-
if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE) && !sum &&
743-
!skb->csum_complete_sw)
744-
netdev_rx_csum_fault(skb->dev);
745-
746-
/* Save checksum complete for later use */
747-
skb->csum = sum;
748-
skb->ip_summed = CHECKSUM_COMPLETE;
749-
skb->csum_complete_sw = 1;
750-
742+
if (likely(!sum)) {
743+
if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE) &&
744+
!skb->csum_complete_sw)
745+
netdev_rx_csum_fault(skb->dev);
746+
}
747+
skb->csum_valid = !sum;
751748
return sum;
752749
}
753750
EXPORT_SYMBOL(__skb_checksum_complete_head);
754751

755752
__sum16 __skb_checksum_complete(struct sk_buff *skb)
756753
{
757-
return __skb_checksum_complete_head(skb, skb->len);
754+
__wsum csum;
755+
__sum16 sum;
756+
757+
csum = skb_checksum(skb, 0, skb->len, 0);
758+
759+
/* skb->csum holds pseudo checksum */
760+
sum = csum_fold(csum_add(skb->csum, csum));
761+
if (likely(!sum)) {
762+
if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE) &&
763+
!skb->csum_complete_sw)
764+
netdev_rx_csum_fault(skb->dev);
765+
}
766+
767+
/* Save full packet checksum */
768+
skb->csum = csum;
769+
skb->ip_summed = CHECKSUM_COMPLETE;
770+
skb->csum_complete_sw = 1;
771+
skb->csum_valid = !sum;
772+
773+
return sum;
758774
}
759775
EXPORT_SYMBOL(__skb_checksum_complete);
760776

net/core/skbuff.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,9 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
689689
new->ooo_okay = old->ooo_okay;
690690
new->no_fcs = old->no_fcs;
691691
new->encapsulation = old->encapsulation;
692+
new->encap_hdr_csum = old->encap_hdr_csum;
693+
new->csum_valid = old->csum_valid;
694+
new->csum_complete_sw = old->csum_complete_sw;
692695
#ifdef CONFIG_XFRM
693696
new->sp = secpath_get(old->sp);
694697
#endif

net/ipv4/udp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,6 +1861,10 @@ static struct sock *__udp4_lib_mcast_demux_lookup(struct net *net,
18611861
unsigned int count, slot = udp_hashfn(net, hnum, udp_table.mask);
18621862
struct udp_hslot *hslot = &udp_table.hash[slot];
18631863

1864+
/* Do not bother scanning a too big list */
1865+
if (hslot->count > 10)
1866+
return NULL;
1867+
18641868
rcu_read_lock();
18651869
begin:
18661870
count = 0;

net/sctp/sysctl.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
* Sridhar Samudrala <[email protected]>
3535
*/
3636

37+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
38+
3739
#include <net/sctp/structs.h>
3840
#include <net/sctp/sctp.h>
3941
#include <linux/sysctl.h>
@@ -46,6 +48,11 @@ static int sack_timer_min = 1;
4648
static int sack_timer_max = 500;
4749
static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */
4850
static int rwnd_scale_max = 16;
51+
static int rto_alpha_min = 0;
52+
static int rto_beta_min = 0;
53+
static int rto_alpha_max = 1000;
54+
static int rto_beta_max = 1000;
55+
4956
static unsigned long max_autoclose_min = 0;
5057
static unsigned long max_autoclose_max =
5158
(MAX_SCHEDULE_TIMEOUT / HZ > UINT_MAX)
@@ -64,6 +71,9 @@ static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
6471
static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
6572
void __user *buffer, size_t *lenp,
6673
loff_t *ppos);
74+
static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,
75+
void __user *buffer, size_t *lenp,
76+
loff_t *ppos);
6777
static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
6878
void __user *buffer, size_t *lenp,
6979
loff_t *ppos);
@@ -126,15 +136,19 @@ static struct ctl_table sctp_net_table[] = {
126136
.procname = "rto_alpha_exp_divisor",
127137
.data = &init_net.sctp.rto_alpha,
128138
.maxlen = sizeof(int),
129-
.mode = 0444,
130-
.proc_handler = proc_dointvec,
139+
.mode = 0644,
140+
.proc_handler = proc_sctp_do_alpha_beta,
141+
.extra1 = &rto_alpha_min,
142+
.extra2 = &rto_alpha_max,
131143
},
132144
{
133145
.procname = "rto_beta_exp_divisor",
134146
.data = &init_net.sctp.rto_beta,
135147
.maxlen = sizeof(int),
136-
.mode = 0444,
137-
.proc_handler = proc_dointvec,
148+
.mode = 0644,
149+
.proc_handler = proc_sctp_do_alpha_beta,
150+
.extra1 = &rto_beta_min,
151+
.extra2 = &rto_beta_max,
138152
},
139153
{
140154
.procname = "max_burst",
@@ -403,6 +417,16 @@ static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
403417
return ret;
404418
}
405419

420+
static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,
421+
void __user *buffer, size_t *lenp,
422+
loff_t *ppos)
423+
{
424+
pr_warn_once("Changing rto_alpha or rto_beta may lead to "
425+
"suboptimal rtt/srtt estimations!\n");
426+
427+
return proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
428+
}
429+
406430
static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
407431
void __user *buffer, size_t *lenp,
408432
loff_t *ppos)

0 commit comments

Comments
 (0)