Skip to content

Commit 46e6b99

Browse files
shemmingerdavem330
authored andcommitted
rtnetlink: allow GSO maximums to be set on device creation
Netlink device already allows changing GSO sizes with ip set command. The part that is missing is allowing overriding GSO settings on device creation. Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5a6a044 commit 46e6b99

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

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)