diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-10-13 15:41:36 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-10-13 15:41:36 +0200 |
commit | 373e702dc8a42e46113906471ae82d6617a2253a (patch) | |
tree | 66026e150ccf5fc8482a7816a0388cf3727a5d1f | |
parent | 48abf838f8fecb58a1abca51084f5cff41cf3d9a (diff) | |
download | modfastd-373e702dc8a42e46113906471ae82d6617a2253a.tar modfastd-373e702dc8a42e46113906471ae82d6617a2253a.zip |
Allow setting MTU on interface creation
-rw-r--r-- | fastd.c | 14 | ||||
-rw-r--r-- | fastd.h | 1 |
2 files changed, 14 insertions, 1 deletions
@@ -63,6 +63,9 @@ #define FASTD_HEADROOM \ (ETH_HLEN + sizeof(struct ipv6hdr) + sizeof(struct udphdr) + 24) +#define FASTD_DEFAULT_MTU 1500 +#define FASTD_MIN_MTU 68 + static LIST_HEAD(fastd_list); static struct workqueue_struct *fastd_workqueue; @@ -195,7 +198,6 @@ static void fastd_netdev_init(struct net_device *dev) dev->addr_len = 0; dev->hard_header_len = FASTD_HEADROOM; - dev->mtu = 1500; dev->type = ARPHRD_NONE; dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; @@ -221,6 +223,7 @@ static int fastd_cmd_create(struct sk_buff *skb, struct genl_info *info) struct net_device *dev; struct fastd_struct *fastd; u16 mode; + u16 mtu = FASTD_DEFAULT_MTU; const char *name = "fastd%d"; int err; @@ -234,6 +237,13 @@ static int fastd_cmd_create(struct sk_buff *skb, struct genl_info *info) if (mode != FASTD_MODE_ETH && mode != FASTD_MODE_IP) return -EINVAL; + if (info->attrs[FASTD_A_MTU]) + mtu = nla_get_u16(info->attrs[FASTD_A_MTU]); + + if (mtu < FASTD_MIN_MTU) + return -EINVAL; + + if (info->attrs[FASTD_A_IFNAME]) name = nla_data(info->attrs[FASTD_A_IFNAME]); @@ -257,6 +267,7 @@ static int fastd_cmd_create(struct sk_buff *skb, struct genl_info *info) INIT_WORK(&fastd->destroy_work, fastd_destroy_work); fastd_netdev_init(dev); + dev->mtu = mtu; rtnl_lock(); err = register_netdevice(dev); @@ -284,6 +295,7 @@ err_module_put: static struct nla_policy fastd_nl_policy[__FASTD_A_MAX] = { [FASTD_A_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ-1 }, [FASTD_A_MODE] = { .type = NLA_U16 }, + [FASTD_A_MTU] = { .type = NLA_U16 }, }; static struct genl_ops fastd_nl_ops[] = { @@ -53,6 +53,7 @@ enum { FASTD_A_UNSPEC, FASTD_A_IFNAME, FASTD_A_MODE, + FASTD_A_MTU, __FASTD_A_MAX }; |