Skip to content

Commit 62fd8b1

Browse files
committed
Merge branch 'veth-and-GSO-maximums'
Stephen Hemminger says: ==================== veth and GSO maximums This is the more general way to solving the issue of GSO limits not being set correctly for containers on Azure. If a GSO packet is sent to host that exceeds the limit (reported by NDIS), then the host is forced to do segmentation in software which has noticeable performance impact. The core rtnetlink infrastructure already has the messages and infrastructure to allow changing gso limits. With an updated iproute2 the following already works: # ip li set dev dummy0 gso_max_size 30000 These patches are about making it easier with veth. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 5a6a044 + 72d2495 commit 62fd8b1

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

drivers/net/veth.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
410410
if (ifmp && (dev->ifindex != 0))
411411
peer->ifindex = ifmp->ifi_index;
412412

413+
peer->gso_max_size = dev->gso_max_size;
414+
peer->gso_max_segs = dev->gso_max_segs;
415+
413416
err = register_netdevice(peer);
414417
put_net(net);
415418
net = NULL;

net/core/rtnetlink.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,8 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = {
16371637
[IFLA_PROMISCUITY] = { .type = NLA_U32 },
16381638
[IFLA_NUM_TX_QUEUES] = { .type = NLA_U32 },
16391639
[IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 },
1640+
[IFLA_GSO_MAX_SEGS] = { .type = NLA_U32 },
1641+
[IFLA_GSO_MAX_SIZE] = { .type = NLA_U32 },
16401642
[IFLA_PHYS_PORT_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN },
16411643
[IFLA_CARRIER_CHANGES] = { .type = NLA_U32 }, /* ignored */
16421644
[IFLA_PHYS_SWITCH_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN },
@@ -2287,6 +2289,34 @@ static int do_setlink(const struct sk_buff *skb,
22872289
}
22882290
}
22892291

2292+
if (tb[IFLA_GSO_MAX_SIZE]) {
2293+
u32 max_size = nla_get_u32(tb[IFLA_GSO_MAX_SIZE]);
2294+
2295+
if (max_size > GSO_MAX_SIZE) {
2296+
err = -EINVAL;
2297+
goto errout;
2298+
}
2299+
2300+
if (dev->gso_max_size ^ max_size) {
2301+
netif_set_gso_max_size(dev, max_size);
2302+
status |= DO_SETLINK_MODIFIED;
2303+
}
2304+
}
2305+
2306+
if (tb[IFLA_GSO_MAX_SEGS]) {
2307+
u32 max_segs = nla_get_u32(tb[IFLA_GSO_MAX_SEGS]);
2308+
2309+
if (max_segs > GSO_MAX_SEGS) {
2310+
err = -EINVAL;
2311+
goto errout;
2312+
}
2313+
2314+
if (dev->gso_max_segs ^ max_segs) {
2315+
dev->gso_max_segs = max_segs;
2316+
status |= DO_SETLINK_MODIFIED;
2317+
}
2318+
}
2319+
22902320
if (tb[IFLA_OPERSTATE])
22912321
set_operstate(dev, nla_get_u8(tb[IFLA_OPERSTATE]));
22922322

@@ -2651,6 +2681,10 @@ struct net_device *rtnl_create_link(struct net *net,
26512681
dev->link_mode = nla_get_u8(tb[IFLA_LINKMODE]);
26522682
if (tb[IFLA_GROUP])
26532683
dev_set_group(dev, nla_get_u32(tb[IFLA_GROUP]));
2684+
if (tb[IFLA_GSO_MAX_SIZE])
2685+
netif_set_gso_max_size(dev, nla_get_u32(tb[IFLA_GSO_MAX_SIZE]));
2686+
if (tb[IFLA_GSO_MAX_SEGS])
2687+
dev->gso_max_size = nla_get_u32(tb[IFLA_GSO_MAX_SEGS]);
26542688

26552689
return dev;
26562690
}

0 commit comments

Comments
 (0)