Message ID | 1455648204-58763-4-git-send-email-joe@ovn.org |
---|---|
State | Not Applicable |
Headers | show |
On Tue, Feb 16, 2016 at 10:43 AM, Joe Stringer <joe@ovn.org> wrote: > diff --git a/datapath/linux/compat/include/net/stt.h b/datapath/linux/compat/include/net/stt.h > index 28d4dc53c061..aa55c9a0a2a5 100644 > --- a/datapath/linux/compat/include/net/stt.h > +++ b/datapath/linux/compat/include/net/stt.h [...] > + err = stt_change_mtu(dev, STT_MAX_MTU); > + if (err) > + return err; Don't we need to unregister the device on error? (I noticed this on LISP too.)
On 16 February 2016 at 14:02, Jesse Gross <jesse@kernel.org> wrote: > On Tue, Feb 16, 2016 at 10:43 AM, Joe Stringer <joe@ovn.org> wrote: >> diff --git a/datapath/linux/compat/include/net/stt.h b/datapath/linux/compat/include/net/stt.h >> index 28d4dc53c061..aa55c9a0a2a5 100644 >> --- a/datapath/linux/compat/include/net/stt.h >> +++ b/datapath/linux/compat/include/net/stt.h > [...] >> + err = stt_change_mtu(dev, STT_MAX_MTU); >> + if (err) >> + return err; > > Don't we need to unregister the device on error? (I noticed this on LISP too.) Probably we could just configure the MTU prior to device registration. Thanks for pointing this out.
diff --git a/datapath/linux/compat/include/net/stt.h b/datapath/linux/compat/include/net/stt.h index 28d4dc53c061..aa55c9a0a2a5 100644 --- a/datapath/linux/compat/include/net/stt.h +++ b/datapath/linux/compat/include/net/stt.h @@ -24,6 +24,8 @@ struct stthdr { #define STT_BASE_HLEN (sizeof(struct stthdr) + STT_ETH_PAD) #define STT_HEADER_LEN (sizeof(struct tcphdr) + STT_BASE_HLEN) +#define STT_MAX_MTU (IP_MAX_MTU - STT_HEADER_LEN - sizeof(struct iphdr) \ + - sizeof(struct ethhdr)) static inline struct stthdr *stt_hdr(const struct sk_buff *skb) { diff --git a/datapath/linux/compat/stt.c b/datapath/linux/compat/stt.c index 527dfeeec236..f6e2744e33cf 100644 --- a/datapath/linux/compat/stt.c +++ b/datapath/linux/compat/stt.c @@ -1683,6 +1683,15 @@ static int stt_stop(struct net_device *dev) return 0; } +static int stt_change_mtu(struct net_device *dev, int new_mtu) +{ + if (new_mtu < 68 || new_mtu > STT_MAX_MTU) + return -EINVAL; + + dev->mtu = new_mtu; + return 0; +} + static const struct net_device_ops stt_netdev_ops = { .ndo_init = stt_init, .ndo_uninit = stt_uninit, @@ -1690,7 +1699,7 @@ static const struct net_device_ops stt_netdev_ops = { .ndo_stop = stt_stop, .ndo_start_xmit = stt_dev_xmit, .ndo_get_stats64 = ip_tunnel_get_stats64, - .ndo_change_mtu = eth_change_mtu, + .ndo_change_mtu = stt_change_mtu, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = eth_mac_addr, }; @@ -1786,6 +1795,10 @@ static int stt_configure(struct net *net, struct net_device *dev, if (err) return err; + err = stt_change_mtu(dev, STT_MAX_MTU); + if (err) + return err; + list_add(&stt->next, &sn->stt_list); return 0; }
Currently, even if the entire path supports jumbo frames, the STT netdev limits the path MTU to 1500 bytes, and cannot be configured otherwise. Relax the constraints on modifying the device MTU, and set it to the maximum by default. Signed-off-by: Joe Stringer <joe@ovn.org> --- datapath/linux/compat/include/net/stt.h | 2 ++ datapath/linux/compat/stt.c | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-)