aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-02-23 23:19:20 -0500
committerDavid S. Miller <davem@davemloft.net>2008-02-23 23:19:20 -0500
commit34cc7ba6398203aab4056917fa1e2aa5988487aa (patch)
tree40fc152c1d9722ca70154bd6d989694fff526280 /net
parent55b01e8681cba392ccda4ff6184054d38968115d (diff)
[IP_TUNNEL]: Don't limit the number of tunnels with generic name explicitly.
Use the added dev_alloc_name() call to create tunnel device name, rather than iterate in a hand-made loop with an artificial limit. Thanks Patrick for noticing this. [ The way this works is, when the device is actually registered, the generic code noticed the '%' in the name and invokes dev_alloc_name() to fully resolve the name. -DaveM ] Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/ip_gre.c12
-rw-r--r--net/ipv4/ipip.c12
-rw-r--r--net/ipv6/ip6_tunnel.c15
-rw-r--r--net/ipv6/sit.c12
4 files changed, 10 insertions, 41 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 63f691719353..906cb1ada4c3 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -259,16 +259,8 @@ static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int
259 259
260 if (parms->name[0]) 260 if (parms->name[0])
261 strlcpy(name, parms->name, IFNAMSIZ); 261 strlcpy(name, parms->name, IFNAMSIZ);
262 else { 262 else
263 int i; 263 sprintf(name, "gre%%d");
264 for (i=1; i<100; i++) {
265 sprintf(name, "gre%d", i);
266 if (__dev_get_by_name(&init_net, name) == NULL)
267 break;
268 }
269 if (i==100)
270 goto failed;
271 }
272 264
273 dev = alloc_netdev(sizeof(*t), name, ipgre_tunnel_setup); 265 dev = alloc_netdev(sizeof(*t), name, ipgre_tunnel_setup);
274 if (!dev) 266 if (!dev)
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index da281581692c..e77e3b855834 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -221,16 +221,8 @@ static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int c
221 221
222 if (parms->name[0]) 222 if (parms->name[0])
223 strlcpy(name, parms->name, IFNAMSIZ); 223 strlcpy(name, parms->name, IFNAMSIZ);
224 else { 224 else
225 int i; 225 sprintf(name, "tunl%%d");
226 for (i=1; i<100; i++) {
227 sprintf(name, "tunl%d", i);
228 if (__dev_get_by_name(&init_net, name) == NULL)
229 break;
230 }
231 if (i==100)
232 goto failed;
233 }
234 226
235 dev = alloc_netdev(sizeof(*t), name, ipip_tunnel_setup); 227 dev = alloc_netdev(sizeof(*t), name, ipip_tunnel_setup);
236 if (dev == NULL) 228 if (dev == NULL)
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index cd940647bd12..2a124e9a1b2d 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -229,18 +229,11 @@ static struct ip6_tnl *ip6_tnl_create(struct ip6_tnl_parm *p)
229 char name[IFNAMSIZ]; 229 char name[IFNAMSIZ];
230 int err; 230 int err;
231 231
232 if (p->name[0]) { 232 if (p->name[0])
233 strlcpy(name, p->name, IFNAMSIZ); 233 strlcpy(name, p->name, IFNAMSIZ);
234 } else { 234 else
235 int i; 235 sprintf(name, "ip6tnl%%d");
236 for (i = 1; i < IP6_TNL_MAX; i++) { 236
237 sprintf(name, "ip6tnl%d", i);
238 if (__dev_get_by_name(&init_net, name) == NULL)
239 break;
240 }
241 if (i == IP6_TNL_MAX)
242 goto failed;
243 }
244 dev = alloc_netdev(sizeof (*t), name, ip6_tnl_dev_setup); 237 dev = alloc_netdev(sizeof (*t), name, ip6_tnl_dev_setup);
245 if (dev == NULL) 238 if (dev == NULL)
246 goto failed; 239 goto failed;
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index e77239d02bf5..dde7801abeff 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -164,16 +164,8 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int
164 164
165 if (parms->name[0]) 165 if (parms->name[0])
166 strlcpy(name, parms->name, IFNAMSIZ); 166 strlcpy(name, parms->name, IFNAMSIZ);
167 else { 167 else
168 int i; 168 sprintf(name, "sit%%d");
169 for (i=1; i<100; i++) {
170 sprintf(name, "sit%d", i);
171 if (__dev_get_by_name(&init_net, name) == NULL)
172 break;
173 }
174 if (i==100)
175 goto failed;
176 }
177 169
178 dev = alloc_netdev(sizeof(*t), name, ipip6_tunnel_setup); 170 dev = alloc_netdev(sizeof(*t), name, ipip6_tunnel_setup);
179 if (dev == NULL) 171 if (dev == NULL)