aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2008-10-09 14:59:32 -0400
committerDavid S. Miller <davem@davemloft.net>2008-10-09 14:59:32 -0400
commit42aa916265d740d66ac1f17290366e9494c884c2 (patch)
tree284d444b14363656fd958c647bce9cb6ab54eba9 /net
parentc95b819ad75b13102139aad0e7062d927be23cc6 (diff)
gre: Move MTU setting out of ipgre_tunnel_bind_dev
This patch moves the dev->mtu setting out of ipgre_tunnel_bind_dev. This is in prepartion of using rtnl_link where we'll need to make the MTU setting conditional on whether the user has supplied an MTU. This also requires the move of the ipgre_tunnel_bind_dev call out of the dev->init function so that we can access the user parameters later. This patch also adds a check to prevent setting the MTU below the minimum of 68. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/ip_gre.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index fd192d676955..80622dd6fb3f 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -119,6 +119,7 @@
119 119
120static int ipgre_tunnel_init(struct net_device *dev); 120static int ipgre_tunnel_init(struct net_device *dev);
121static void ipgre_tunnel_setup(struct net_device *dev); 121static void ipgre_tunnel_setup(struct net_device *dev);
122static int ipgre_tunnel_bind_dev(struct net_device *dev);
122 123
123/* Fallback tunnel: no source, no destination, no key, no options */ 124/* Fallback tunnel: no source, no destination, no key, no options */
124 125
@@ -289,6 +290,8 @@ static struct ip_tunnel * ipgre_tunnel_locate(struct net *net,
289 nt = netdev_priv(dev); 290 nt = netdev_priv(dev);
290 nt->parms = *parms; 291 nt->parms = *parms;
291 292
293 dev->mtu = ipgre_tunnel_bind_dev(dev);
294
292 if (register_netdevice(dev) < 0) 295 if (register_netdevice(dev) < 0)
293 goto failed_free; 296 goto failed_free;
294 297
@@ -773,7 +776,7 @@ tx_error:
773 return 0; 776 return 0;
774} 777}
775 778
776static void ipgre_tunnel_bind_dev(struct net_device *dev) 779static int ipgre_tunnel_bind_dev(struct net_device *dev)
777{ 780{
778 struct net_device *tdev = NULL; 781 struct net_device *tdev = NULL;
779 struct ip_tunnel *tunnel; 782 struct ip_tunnel *tunnel;
@@ -821,9 +824,14 @@ static void ipgre_tunnel_bind_dev(struct net_device *dev)
821 addend += 4; 824 addend += 4;
822 } 825 }
823 dev->needed_headroom = addend + hlen; 826 dev->needed_headroom = addend + hlen;
824 dev->mtu = mtu - dev->hard_header_len - addend; 827 mtu -= dev->hard_header_len - addend;
828
829 if (mtu < 68)
830 mtu = 68;
831
825 tunnel->hlen = addend; 832 tunnel->hlen = addend;
826 833
834 return mtu;
827} 835}
828 836
829static int 837static int
@@ -917,7 +925,7 @@ ipgre_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
917 t->parms.iph.frag_off = p.iph.frag_off; 925 t->parms.iph.frag_off = p.iph.frag_off;
918 if (t->parms.link != p.link) { 926 if (t->parms.link != p.link) {
919 t->parms.link = p.link; 927 t->parms.link = p.link;
920 ipgre_tunnel_bind_dev(dev); 928 dev->mtu = ipgre_tunnel_bind_dev(dev);
921 netdev_state_change(dev); 929 netdev_state_change(dev);
922 } 930 }
923 } 931 }
@@ -1108,8 +1116,6 @@ static int ipgre_tunnel_init(struct net_device *dev)
1108 memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4); 1116 memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4);
1109 memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4); 1117 memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4);
1110 1118
1111 ipgre_tunnel_bind_dev(dev);
1112
1113 if (iph->daddr) { 1119 if (iph->daddr) {
1114#ifdef CONFIG_NET_IPGRE_BROADCAST 1120#ifdef CONFIG_NET_IPGRE_BROADCAST
1115 if (ipv4_is_multicast(iph->daddr)) { 1121 if (ipv4_is_multicast(iph->daddr)) {