summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fastd.c14
-rw-r--r--fastd.h1
2 files changed, 14 insertions, 1 deletions
diff --git a/fastd.c b/fastd.c
index 98b6565..7373e86 100644
--- a/fastd.c
+++ b/fastd.c
@@ -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[] = {
diff --git a/fastd.h b/fastd.h
index 026846a..5c3ca86 100644
--- a/fastd.h
+++ b/fastd.h
@@ -53,6 +53,7 @@ enum {
FASTD_A_UNSPEC,
FASTD_A_IFNAME,
FASTD_A_MODE,
+ FASTD_A_MTU,
__FASTD_A_MAX
};