OpenVZ Forum - RDF feed
type: channel
items: Dynamically allocate the loopback device
items: Re: Dynamically allocate the loopback device

Dynamically allocate the loopback device
type: item
description: From: Daniel Lezcano <dlezcano@fr.ibm.com> Doing this makes loopback.c a better example of how to do a simple network device, and it removes the special case single static allocation of a struct net_device, hopefully making maintenance easier. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> --- drivers/net/loopback.c | 63 +++++++++++++++++++++++--------------- include/linux/netdevice.h | 2 +- net/core/dst.c | 8 ++-- net/decnet/dn_dev.c | 4 +- net/decnet/dn_route.c | 14 ++++---- net/ipv4/devinet.c | 6 ++-- net/ipv4/ipconfig.c | 6 ++-- net/ipv4/ipvs/ip_vs_core.c | 2 +- net/ipv4/route.c | 18 +++++----- net/ipv4/xfrm4_policy.c | 2 +- net/ipv6/addrconf.c | 15 +++++--- net/ipv6/ip6_input.c | 2 +- net/ipv6/netfilter/ip6t_REJECT.c | 2 +- net/ipv6/route.c | 15 +++----- net/ipv6/xfrm6_policy.c | 2 +- net/xfrm/xfrm_policy.c | 4 +- 16 files changed, 89 insertions(+), 76 deletions(-) diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 5106c23..3642aff 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -199,44 +199,57 @@ static const struct ethtool_ops loopback_ethtool_ops = { .get_rx_csum = always_on, }; -/* - * The loopback device is special. There is only one instance and - * it is statically allocated. Don't do this for other devices. - */ -struct net_device loopback_dev = { - .name = "lo", - .get_stats = &get_stats, - .mtu = (16 * 1024) + 20 + 20 + 12, - .hard_start_xmit = loopback_xmit, - .hard_header = eth_header, - .hard_header_cache = eth_header_cache, - .header_cache_update = eth_header_cache_update, - .hard_header_len = ETH_HLEN, /* 14 */ - .addr_len = ETH_ALEN, /* 6 */ - .tx_queue_len = 0, - .type = ARPHRD_LOOPBACK, /* 0x0001*/ - .rebuild_header = eth_rebuild_header, - .flags = IFF_LOOPBACK, - .features = NETIF_F_SG | NETIF_F_FRAGLIST +static void loopback_setup(struct net_device *dev) +{ + dev->get_stats = &get_stats; + dev->mtu = (16 * 1024) + 20 + 20 + 12; + dev->hard_start…
creator: Daniel Lezcano
date: 2007-08-24T12:50:25-00:00

Re: Dynamically allocate the loopback device
type: item
description: Acked-By: Kirill Korotaev <dev@sw.ru> dlezcano@fr.ibm.com wrote: > From: Daniel Lezcano <dlezcano@fr.ibm.com> > > Doing this makes loopback.c a better example of how to do a > simple network device, and it removes the special case > single static allocation of a struct net_device, hopefully > making maintenance easier. > > Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> > Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> > --- > drivers/net/loopback.c | 63 +++++++++++++++++++++++--------------- > include/linux/netdevice.h | 2 +- > net/core/dst.c | 8 ++-- > net/decnet/dn_dev.c | 4 +- > net/decnet/dn_route.c | 14 ++++---- > net/ipv4/devinet.c | 6 ++-- > net/ipv4/ipconfig.c | 6 ++-- > net/ipv4/ipvs/ip_vs_core.c | 2 +- > net/ipv4/route.c | 18 +++++----- > net/ipv4/xfrm4_policy.c | 2 +- > net/ipv6/addrconf.c | 15 +++++--- > net/ipv6/ip6_input.c | 2 +- > net/ipv6/netfilter/ip6t_REJECT.c | 2 +- > net/ipv6/route.c | 15 +++----- > net/ipv6/xfrm6_policy.c | 2 +- > net/xfrm/xfrm_policy.c | 4 +- > 16 files changed, 89 insertions(+), 76 deletions(-) > > diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c > index 5106c23..3642aff 100644 > --- a/drivers/net/loopback.c > +++ b/drivers/net/loopback.c > @@ -199,44 +199,57 @@ static const struct ethtool_ops loopback_ethtool_ops = { > .get_rx_csum = always_on, > }; > > -/* > - * The loopback device is special. There is only one instance and > - * it is statically allocated. Don't do this for other devices. > - */ > -struct net_device loopback_dev = { > - .name = "lo", > - .get_stats = &get_stats, > - .mtu = (16 * 1024) + 20 + 20 + 12, > - .hard_start_xmit = loopback_xmit, > - .hard_header = eth_header, > - .hard_header_cache = eth_header_cache, > - .header_cache_update = eth_header_cache_update, > - .hard_header_len = ETH_HLEN, /* 14 */ > - .addr_len = ETH_ALEN, /* 6 */ > - .tx_queue_len = 0, > - .type = ARPHRD_LOOPBACK, /* 0x0001*/ > - .rebuild_header = eth_rebuild_header, > - .flags = IFF_LOOPBACK, > - .features =…
creator: dev
date: 2007-08-24T13:06:58-00:00

Re: Dynamically allocate the loopback device
type: item
description: Kirill Korotaev wrote: > Acked-By: Kirill Korotaev <dev@sw.ru> Acked-by: Benjamin Thery <benjamin.thery@bull.net> Looks good to me. Compiled and tested on i386. > > dlezcano@fr.ibm.com wrote: >> From: Daniel Lezcano <dlezcano@fr.ibm.com> >> >> Doing this makes loopback.c a better example of how to do a >> simple network device, and it removes the special case >> single static allocation of a struct net_device, hopefully >> making maintenance easier. >> >> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> >> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> >> --- >> drivers/net/loopback.c | 63 +++++++++++++++++++++++--------------- >> include/linux/netdevice.h | 2 +- >> net/core/dst.c | 8 ++-- >> net/decnet/dn_dev.c | 4 +- >> net/decnet/dn_route.c | 14 ++++---- >> net/ipv4/devinet.c | 6 ++-- >> net/ipv4/ipconfig.c | 6 ++-- >> net/ipv4/ipvs/ip_vs_core.c | 2 +- >> net/ipv4/route.c | 18 +++++----- >> net/ipv4/xfrm4_policy.c | 2 +- >> net/ipv6/addrconf.c | 15 +++++--- >> net/ipv6/ip6_input.c | 2 +- >> net/ipv6/netfilter/ip6t_REJECT.c | 2 +- >> net/ipv6/route.c | 15 +++----- >> net/ipv6/xfrm6_policy.c | 2 +- >> net/xfrm/xfrm_policy.c | 4 +- >> 16 files changed, 89 insertions(+), 76 deletions(-) >> >> diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c >> index 5106c23..3642aff 100644 >> --- a/drivers/net/loopback.c >> +++ b/drivers/net/loopback.c >> @@ -199,44 +199,57 @@ static const struct ethtool_ops loopback_ethtool_ops = { >> .get_rx_csum = always_on, >> }; >> >> -/* >> - * The loopback device is special. There is only one instance and >> - * it is statically allocated. Don't do this for other devices. >> - */ >> -struct net_device loopback_dev = { >> - .name = "lo", >> - .get_stats = &get_stats, >> - .mtu = (16 * 1024) + 20 + 20 + 12, >> - .hard_start_xmit = loopback_xmit, >> - .hard_header = eth_header, >> - .hard_header_cache = eth_header_cache, >> - .header_cache_update = eth_header_cache_update, >> - .hard_header_len = ETH_HLEN, /* 14 */ >> - .…
creator: Benjamin Thery
date: 2007-08-24T13:22:27-00:00