History

vxlan: Use checksum partial with remote checksum offload

Change remote checksum handling to set checksum partial as default behavior. Added an iflink parameter to configure not using checksum partial (calling csum_partial to update checksum).

Tom Herbert committed 11 years ago

Commit 0ace2ca1 parent 15e23963 files · +23 −7Browse files

Unified · Split

3 files
  1. drivers/net/vxlan.c +19 −6
  2. include/net/vxlan.h +3 −1
  3. include/uapi/linux/if_link.h +1 −0
drivers/net/vxlan.c+19−6
@@ -555,7 +555,8 @@ static int vxlan_fdb_append(struct vxlan_fdb *f, · 554 unmodified lines
555555 static struct vxlanhdr *vxlan_gro_remcsum(struct sk_buff *skb,
556556 unsigned int off,
557557 struct vxlanhdr *vh, size_t hdrlen,
558− u32 data, struct gro_remcsum *grc)
558+ u32 data, struct gro_remcsum *grc,
559+ bool nopartial)
559560 {
560561 size_t start, offset, plen;
561562
@@ -580,7 +581,7 @@ static struct vxlanhdr *vxlan_gro_remcsum(struct sk_buff *skb, · 18 unmodified lines
580581 }
581582
582583 skb_gro_remcsum_process(skb, (void *)vh + hdrlen,
583− start, offset, grc, true);
584+ start, offset, grc, nopartial);
584585
585586 skb->remcsum_offload = 1;
586587
@@ -618,7 +619,9 @@ static struct sk_buff **vxlan_gro_receive(struct sk_buff **head, · 31 unmodified lines
618619
619620 if ((flags & VXLAN_HF_RCO) && (vs->flags & VXLAN_F_REMCSUM_RX)) {
620621 vh = vxlan_gro_remcsum(skb, off_vx, vh, sizeof(struct vxlanhdr),
621− ntohl(vh->vx_vni), &grc);
622+ ntohl(vh->vx_vni), &grc,
623+ !!(vs->flags &
624+ VXLAN_F_REMCSUM_NOPARTIAL));
622625
623626 if (!vh)
624627 goto out;
@@ -1155,7 +1158,7 @@ static void vxlan_igmp_leave(struct work_struct *work) · 530 unmodified lines
11551158 }
11561159
11571160 static struct vxlanhdr *vxlan_remcsum(struct sk_buff *skb, struct vxlanhdr *vh,
1158− size_t hdrlen, u32 data)
1161+ size_t hdrlen, u32 data, bool nopartial)
11591162 {
11601163 size_t start, offset, plen;
11611164
@@ -1171,7 +1174,8 @@ static struct vxlanhdr *vxlan_remcsum(struct sk_buff *skb, struct vxlanhdr *vh, · 9 unmodified lines
11711174
11721175 vh = (struct vxlanhdr *)(udp_hdr(skb) + 1);
11731176
1174− skb_remcsum_process(skb, (void *)vh + hdrlen, start, offset, true);
1177+ skb_remcsum_process(skb, (void *)vh + hdrlen, start, offset,
1178+ nopartial);
11751179
11761180 return vh;
11771181 }
@@ -1208,7 +1212,8 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb) · 30 unmodified lines
12081212 goto drop;
12091213
12101214 if ((flags & VXLAN_HF_RCO) && (vs->flags & VXLAN_F_REMCSUM_RX)) {
1211− vxh = vxlan_remcsum(skb, vxh, sizeof(struct vxlanhdr), vni);
1215+ vxh = vxlan_remcsum(skb, vxh, sizeof(struct vxlanhdr), vni,
1216+ !!(vs->flags & VXLAN_F_REMCSUM_NOPARTIAL));
12121217 if (!vxh)
12131218 goto drop;
12141219
@@ -2437,6 +2442,7 @@ static const struct nla_policy vxlan_policy[IFLA_VXLAN_MAX + 1] = { · 1222 unmodified lines
24372442 [IFLA_VXLAN_REMCSUM_TX] = { .type = NLA_U8 },
24382443 [IFLA_VXLAN_REMCSUM_RX] = { .type = NLA_U8 },
24392444 [IFLA_VXLAN_GBP] = { .type = NLA_FLAG, },
2445+ [IFLA_VXLAN_REMCSUM_NOPARTIAL] = { .type = NLA_FLAG },
24402446 };
24412447
24422448 static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[])
@@ -2760,6 +2766,9 @@ static int vxlan_newlink(struct net *src_net, struct net_device *dev, · 317 unmodified lines
27602766 if (data[IFLA_VXLAN_GBP])
27612767 vxlan->flags |= VXLAN_F_GBP;
27622768
2769+ if (data[IFLA_VXLAN_REMCSUM_NOPARTIAL])
2770+ vxlan->flags |= VXLAN_F_REMCSUM_NOPARTIAL;
2771+
27632772 if (vxlan_find_vni(src_net, vni, use_ipv6 ? AF_INET6 : AF_INET,
27642773 vxlan->dst_port, vxlan->flags)) {
27652774 pr_info("duplicate VNI %u\n", vni);
@@ -2909,6 +2918,10 @@ static int vxlan_fill_info(struct sk_buff *skb, const struct net_device *dev) · 143 unmodified lines
29092918 nla_put_flag(skb, IFLA_VXLAN_GBP))
29102919 goto nla_put_failure;
29112920
2921+ if (vxlan->flags & VXLAN_F_REMCSUM_NOPARTIAL &&
2922+ nla_put_flag(skb, IFLA_VXLAN_REMCSUM_NOPARTIAL))
2923+ goto nla_put_failure;
2924+
29122925 return 0;
29132926
29142927 nla_put_failure:
include/net/vxlan.h+3−1
@@ -128,13 +128,15 @@ struct vxlan_sock { · 127 unmodified lines
128128 #define VXLAN_F_REMCSUM_TX 0x200
129129 #define VXLAN_F_REMCSUM_RX 0x400
130130 #define VXLAN_F_GBP 0x800
131+#define VXLAN_F_REMCSUM_NOPARTIAL 0x1000
131132
132133 /* Flags that are used in the receive patch. These flags must match in
133134 * order for a socket to be shareable
134135 */
135136 #define VXLAN_F_RCV_FLAGS (VXLAN_F_GBP | \
136137 VXLAN_F_UDP_ZERO_CSUM6_RX | \
137− VXLAN_F_REMCSUM_RX)
138+ VXLAN_F_REMCSUM_RX | \
139+ VXLAN_F_REMCSUM_NOPARTIAL)
138140
139141 struct vxlan_sock *vxlan_sock_add(struct net *net, __be16 port,
140142 vxlan_rcv_t *rcv, void *data,
include/uapi/linux/if_link.h+1−0
@@ -374,6 +374,7 @@ enum { · 373 unmodified lines
374374 IFLA_VXLAN_REMCSUM_TX,
375375 IFLA_VXLAN_REMCSUM_RX,
376376 IFLA_VXLAN_GBP,
377+ IFLA_VXLAN_REMCSUM_NOPARTIAL,
377378 __IFLA_VXLAN_MAX
378379 };
379380 #define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)