Re: [patch v1, kernel version 3.2.1] net/ipv4/ip_gre: Ethernetmultipoint GRE over IP

From: Štefan Gula
Date: Mon Jan 16 2012 - 09:06:05 EST


DÅa 16. januÃra 2012 14:19, Eric Dumazet <eric.dumazet@xxxxxxxxx> napÃsal/a:
> Le lundi 16 janvier 2012 Ã 13:13 +0100, Åtefan Gula a Ãcrit :
>> From: Stefan Gula <steweg@xxxxxxxxx
>>
>> This patch is an extension for current Ethernet over GRE
>> implementation, which allows user to create virtual bridge (multipoint
>> VPN) and forward traffic based on Ethernet MAC address informations in
>> it. It simulates the Bridge bahaviour learing mechanism, but instead
>> of learning port ID from which given MAC address comes, it learns IP
>> address of peer which encapsulated given packet. Multicast, Broadcast
>> and unknown-multicast traffic is send over network as multicast
>> enacapsulated GRE packet, so one Ethernet multipoint GRE tunnel can be
>> represented as one single virtual switch on logical level and be also
>> represented as one multicast IPv4 address on network level.
>>
>> Signed-off-by: Stefan Gula <steweg@xxxxxxxxx>
>>
>> ---
>>
>> Patch was tested for more than one year in real network infrastructure
>> consisting of 98 Linux based access-points
>>
>
> OK, but please always send new patches on top on net-next tree.
>
>> diff -uprN -X linux-3.2.1-orig/Documentation/dontdiff
>> linux-3.2.1-orig/Documentation/dontdiff
>> linux-3.2.1-my/Documentation/dontdiff
>> --- linux-3.2.1-orig/Documentation/dontdiff  2012-01-16 12:32:18.000000000 +0100
>> +++ linux-3.2.1-my/Documentation/dontdiff   2012-01-12 20:42:45.000000000 +0100
>> @@ -260,5 +260,3 @@ wakeup.lds
>> ÂzImage*
>> Âzconf.hash.c
>> Âzoffset.h
>> -mkpiggy
>> -mdp
>
> Hmm, what is this ?
Sorry, this one is not related to my patch, I have follwed the
guideline and those 2 files always end-up in my diff file even I
didn't modify them, so I have added them into dontdiff file assuming
that that file will not pop-up in my diff file. Apparently wrong
assumption, so please ignore those lines

>
>> diff -uprN -X linux-3.2.1-orig/Documentation/dontdiff
>> linux-3.2.1-orig/include/net/ipip.h linux-3.2.1-my/include/net/ipip.h
>> --- linux-3.2.1-orig/include/net/ipip.h    2012-01-12 20:42:45.000000000 +0100
>> +++ linux-3.2.1-my/include/net/ipip.h 2012-01-16 11:17:01.000000000 +0100
>> @@ -27,6 +27,14 @@ struct ip_tunnel {
>> Â Â Â __u32 Â Â Â Â Â Â Â Â Â o_seqno; Â Â Â Â/* The last output seqno */
>>    int           hlen;      /* Precalculated GRE header length */
>>    int           mlink;
>> +#ifdef CONFIG_NET_IPGRE_BRIDGE
>> +#define GRETAP_BR_HASH_BITS 8
>> +#define GRETAP_BR_HASH_SIZE (1 << GRETAP_BR_HASH_BITS)
>> +   struct hlist_head    hash[GRETAP_BR_HASH_SIZE];
>> +   spinlock_t       Âhash_lock;
>> +   unsigned long      ageing_time;
>> +   struct timer_list    gc_timer;
>> +#endif
>>
>>    struct ip_tunnel_parm  parms;
>>
>> diff -uprN -X linux-3.2.1-orig/Documentation/dontdiff
>> linux-3.2.1-orig/net/ipv4/Kconfig linux-3.2.1-my/net/ipv4/Kconfig
>> --- linux-3.2.1-orig/net/ipv4/Kconfig 2012-01-12 20:42:45.000000000 +0100
>> +++ linux-3.2.1-my/net/ipv4/Kconfig  2012-01-16 12:37:00.000000000 +0100
>> @@ -211,6 +211,15 @@ config NET_IPGRE_BROADCAST
>> Â Â Â Â Network), but can be distributed all over the Internet. If you want
>> Â Â Â Â to do that, say Y here and to "IP multicast routing" below.
>>
>> +config NET_IPGRE_BRIDGE
>> + Â Â bool "IP: Ethernet over multipoint GRE over IP"
>> + Â Â depends on IP_MULTICAST && NET_IPGRE && NET_IPGRE_BROADCAST
>> + Â Â help
>> + Â Â Â Allows you to use multipoint GRE VPN as virtual switch and interconnect
>> + Â Â Â several L2 endpoints over L3 routed infrastructure. It is useful for
>> + Â Â Â creating multipoint L2 VPNs which can be later used inside bridge
>> + Â Â Â interfaces If you want to use. GRE multipoint L2 VPN feature say Y.
>> +
>> Âconfig IP_MROUTE
>> Â Â Â bool "IP: multicast routing"
>> Â Â Â depends on IP_MULTICAST
>> diff -uprN -X linux-3.2.1-orig/Documentation/dontdiff
>> linux-3.2.1-orig/net/ipv4/ip_gre.c linux-3.2.1-my/net/ipv4/ip_gre.c
>> --- linux-3.2.1-orig/net/ipv4/ip_gre.c    Â2012-01-12 20:42:45.000000000 +0100
>> +++ linux-3.2.1-my/net/ipv4/ip_gre.c Â2012-01-16 12:29:03.000000000 +0100
>> @@ -52,6 +52,11 @@
>> Â#include <net/ip6_route.h>
>> Â#endif
>>
>> +#ifdef CONFIG_NET_IPGRE_BRIDGE
>> +#include <linux/jhash.h>
>> +#include <asm/unaligned.h>
>> +#endif
>> +
>> Â/*
>> Â Â Problems & solutions
>> Â Â --------------------
>> @@ -134,6 +139,199 @@ struct ipgre_net {
>> Â Â Â struct net_device *fb_tunnel_dev;
>> Â};
>>
>> +#ifdef CONFIG_NET_IPGRE_BRIDGE
>> + Â Â /*
>> + Â Â Â* This part of code includes codes to enable L2 ethernet
>> + Â Â Â* switch virtualization over IP routed infrastructure with
>> + Â Â Â* utilization of multicast capable endpoint using Ethernet
>> + Â Â Â* over GRE
>> + Â Â Â*
>> + Â Â Â* Author: Stefan Gula
>> + Â Â Â* Signed-off-by: Stefan Gula <steweg@xxxxxxxxx>
>> + Â Â Â*/
>> +struct mac_addr {
>> +   unsigned char  addr[6];
>
> Not sure if you need a 'struct mac_addr' for this...
>
> Â Â Â Âunsigned char mac_addr[ETH_ALEN] ?
not sure either, but I used in that time when I developed the code. Do
I have to change that to make this patch to kernel?
>> +};
>> +
>> +struct ipgre_tap_bridge_entry {
>> +   struct hlist_node    hlist;
>> + Â Â u32 Â Â Â Â Â Â Â Â Â Â raddr;
>> +   struct mac_addr     addr;
>> +   struct net_device    *dev;
>> +   struct rcu_head     rcu;
>> +   atomic_t        Âuse_count;
>> +   unsigned long      ageing_timer;
>
>
>> +};
>> +
>> +static struct kmem_cache *ipgre_tap_bridge_cache __read_mostly;
>> +static u32 ipgre_salt __read_mostly;
>> +
>> +static inline int ipgre_tap_bridge_hash(const unsigned char *mac)
>> +{
>> + Â Â u32 key = get_unaligned((u32 *)(mac + 2));
>> + Â Â return jhash_1word(key, ipgre_salt) & (GRETAP_BR_HASH_SIZE - 1);
>> +}
>> +
>> +static inline int ipgre_tap_bridge_has_expired(const struct ip_tunnel *tunnel,
>> + Â Â Â Â Â Â const struct ipgre_tap_bridge_entry *entry)
>> +{
>> + Â Â return time_before_eq(entry->ageing_timer + tunnel->ageing_time,
>> + Â Â Â Â Â Â jiffies);
>> +}
>> +
>> +static void ipgre_tap_bridge_rcu_free(struct rcu_head *head)
>> +{
>> + Â Â struct ipgre_tap_bridge_entry *entry
>> + Â Â Â Â Â Â = container_of(head, struct ipgre_tap_bridge_entry, rcu);
>> + Â Â kmem_cache_free(ipgre_tap_bridge_cache, entry);
>> +}
>> +
>> +void ipgre_tap_bridge_put(struct ipgre_tap_bridge_entry *entry)
>> +{
>> + Â Â if (atomic_dec_and_test(&entry->use_count))
>> + Â Â Â Â Â Â call_rcu(&entry->rcu, ipgre_tap_bridge_rcu_free);
>
> Â Â Â ÂYou can now use kfree_rcu() and get rid of ipgre_tap_bridge_rcu_free()
hmm... for that part of code was copy & pasted from linux bridge code
from version 2.6.26. Do I have to change that or is it optional?
>
>> +}
>> +
>> +static inline void ipgre_tap_bridge_delete(struct
>> ipgre_tap_bridge_entry *entry)
>> +{
>> + Â Â hlist_del_rcu(&entry->hlist);
>> + Â Â ipgre_tap_bridge_put(entry);
>> +}
>> +
>> +static struct ipgre_tap_bridge_entry *ipgre_tap_bridge_create(
>> + Â Â Â Â Â Â struct hlist_head *head,
>> + Â Â Â Â Â Â u32 source,
>> + Â Â Â Â Â Â const unsigned char *addr, struct net_device *dev)
>> +{
>> + Â Â struct ipgre_tap_bridge_entry *entry;
>> + Â Â entry = kmem_cache_alloc(ipgre_tap_bridge_cache, GFP_ATOMIC);
>> + Â Â if (entry) {
>> + Â Â Â Â Â Â memcpy(entry->addr.addr, addr, ETH_ALEN);
>> + Â Â Â Â Â Â atomic_set(&entry->use_count, 1);
>> + Â Â Â Â Â Â hlist_add_head_rcu(&entry->hlist, head);
>> + Â Â Â Â Â Â entry->raddr = source;
>> + Â Â Â Â Â Â entry->ageing_timer = jiffies;
>> + Â Â Â Â Â Â entry->dev = dev;
>> + Â Â }
>> + Â Â return entry;
>> +}
>> +
>> +struct ipgre_tap_bridge_entry *__ipgre_tap_bridge_get(struct ip_tunnel *tunnel,
>> + Â Â const unsigned char *addr)
>> +{
>> + Â Â struct hlist_node *h;
>> + Â Â struct ipgre_tap_bridge_entry *entry;
>> + Â Â hlist_for_each_entry_rcu(entry, h,
>> + Â Â Â Â Â Â &tunnel->hash[ipgre_tap_bridge_hash(addr)], hlist)
>> + Â Â {
>> + Â Â Â Â Â Â if (!compare_ether_addr(entry->addr.addr, addr)) {
>> + Â Â Â Â Â Â Â Â Â Â if (unlikely(ipgre_tap_bridge_has_expired(tunnel,
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â entry)))
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â break;
>> + Â Â Â Â Â Â Â Â Â Â return entry;
>> + Â Â Â Â Â Â }
>> + Â Â }
>> +
>> + Â Â return NULL;
>> +}
>> +
>> +struct ipgre_tap_bridge_entry *ipgre_tap_bridge_get(struct ip_tunnel *tunnel,
>> + Â Â const unsigned char *addr)
>> +{
>> + Â Â struct ipgre_tap_bridge_entry *entry;
>> + Â Â rcu_read_lock();
>> + Â Â entry = __ipgre_tap_bridge_get(tunnel, addr);
>> + Â Â if (entry && !atomic_inc_not_zero(&entry->use_count))
>> + Â Â Â Â Â Â entry = NULL;
>> + Â Â rcu_read_unlock();
>> + Â Â return entry;
>> +}
>> +
>
> Unfortunately you call ipgre_tap_bridge_get() from
> ipgre_tap_bridge_get_raddr() but you dont release the refcount on
> use_count. Leak in ipgre_tunnel_xmit()
>
>
>> +__be32 ipgre_tap_bridge_get_raddr(struct ip_tunnel *tunnel,
>> + Â Â const unsigned char *addr)
>> +{
>> + Â Â struct ipgre_tap_bridge_entry *entry;
>> + Â Â entry = ipgre_tap_bridge_get(tunnel, addr);
>
> Â Â Â ÂSo maybe you want __ipgre_tap_bridge_get(tunnel, addr); here ?
>
Hmmm.. I am sorry, I am maybe not that expert on C coding, as most of
the codes were copied from linux bridge code. Can you give me a hint
how should I change that?

>> + Â Â if (entry == NULL)
>> + Â Â Â Â Â Â return 0;
>> + Â Â else
>> + Â Â Â Â Â Â return entry->raddr;
>> +}
>> +
>> +
>> +static inline struct ipgre_tap_bridge_entry *ipgre_tap_bridge_find(
>> + Â Â struct hlist_head *head,
>> + Â Â const unsigned char *addr)
>> +{
>> + Â Â struct hlist_node *h;
>> + Â Â struct ipgre_tap_bridge_entry *entry;
>> + Â Â hlist_for_each_entry_rcu(entry, h, head, hlist) {
>> + Â Â Â Â Â Â if (!compare_ether_addr(entry->addr.addr, addr))
>
>
>
>> + Â Â Â Â Â Â Â Â Â Â return entry;
>> + Â Â }
>> + Â Â return NULL;
>> +}
>> +
>> +int ipgre_tap_bridge_init(void)
>> +{
>> + Â Â ipgre_tap_bridge_cache = kmem_cache_create("ipgre_tap_bridge_cache",
>> + Â Â Â Â Â Â sizeof(struct ipgre_tap_bridge_entry),
>> + Â Â Â Â Â Â 0,
>> + Â Â Â Â Â Â SLAB_HWCACHE_ALIGN, NULL);
>> + Â Â if (!ipgre_tap_bridge_cache)
>> + Â Â Â Â Â Â return -ENOMEM;
>> + Â Â get_random_bytes(&ipgre_salt, sizeof(ipgre_salt));
>> + Â Â return 0;
>> +}
>> +
>> +void ipgre_tap_bridge_fini(void)
>> +{
>> + Â Â kmem_cache_destroy(ipgre_tap_bridge_cache);
>> +}
>> +
>> +void ipgre_tap_bridge_cleanup(unsigned long _data)
>> +{
>> + Â Â struct ip_tunnel *tunnel = (struct ip_tunnel *)_data;
>> + Â Â unsigned long delay = tunnel->ageing_time;
>> + Â Â unsigned long next_timer = jiffies + tunnel->ageing_time;
>> + Â Â int i;
>> + Â Â spin_lock_bh(&tunnel->hash_lock);
>
> Since you are called from timer, no need to use _bh() variant.
again copied structure from linux bridge code
>
>
> Â Â Â Âspin_lock(&tunnel->hash_lock);
>
>> + Â Â for (i = 0; i < GRETAP_BR_HASH_SIZE; i++) {
>> + Â Â Â Â Â Â struct ipgre_tap_bridge_entry *entry;
>> + Â Â Â Â Â Â struct hlist_node *h, *n;
>> + Â Â Â Â Â Â hlist_for_each_entry_safe(entry, h, n,
>> + Â Â Â Â Â Â Â Â Â Â &tunnel->hash[i], hlist)
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â Â Â unsigned long this_timer;
>> + Â Â Â Â Â Â Â Â Â Â this_timer = entry->ageing_timer + delay;
>> + Â Â Â Â Â Â Â Â Â Â if (time_before_eq(this_timer, jiffies))
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â ipgre_tap_bridge_delete(entry);
>> + Â Â Â Â Â Â Â Â Â Â else if (time_before(this_timer, next_timer))
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â next_timer = this_timer;
>> + Â Â Â Â Â Â }
>> + Â Â }
>> + Â Â spin_unlock_bh(&tunnel->hash_lock);
>> + Â Â mod_timer(&tunnel->gc_timer, round_jiffies(next_timer + HZ/4));
>
> wow... why setup a 250 ms timer, if entries are valid 300 seconds ?
no idea, it was in original linux bridge code
>
>
>
>> +}
>> +
>> +void ipgre_tap_bridge_flush(struct ip_tunnel *tunnel)
>> +{
>> + Â Â int i;
>> + Â Â spin_lock_bh(&tunnel->hash_lock);
>> + Â Â for (i = 0; i < GRETAP_BR_HASH_SIZE; i++) {
>> + Â Â Â Â Â Â struct ipgre_tap_bridge_entry *entry;
>> + Â Â Â Â Â Â struct hlist_node *h, *n;
>> + Â Â Â Â Â Â hlist_for_each_entry_safe(entry, h, n,
>> + Â Â Â Â Â Â Â Â Â Â &tunnel->hash[i], hlist)
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â Â Â ipgre_tap_bridge_delete(entry);
>> + Â Â Â Â Â Â }
>> + Â Â }
>> + Â Â spin_unlock_bh(&tunnel->hash_lock);
>> +}
>> +
>> +#endif
>> +
>> Â/* Tunnel hash table */
>>
>> Â/*
>> @@ -563,6 +761,13 @@ static int ipgre_rcv(struct sk_buff *skb
>>    int  Âoffset = 4;
>> Â Â Â __be16 gre_proto;
>>
>> +#ifdef CONFIG_NET_IPGRE_BRIDGE
>> + Â Â u32 orig_source;
>> + Â Â struct hlist_head *head;
>> + Â Â struct ipgre_tap_bridge_entry *entry;
>> + Â Â struct ethhdr *tethhdr;
>> +#endif
>> +
>> Â Â Â if (!pskb_may_pull(skb, 16))
>> Â Â Â Â Â Â Â goto drop_nolock;
>>
>> @@ -659,10 +864,38 @@ static int ipgre_rcv(struct sk_buff *skb
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tunnel->dev->stats.rx_errors++;
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â goto drop;
>> Â Â Â Â Â Â Â Â Â Â Â }
>> -
>> +#ifdef CONFIG_NET_IPGRE_BRIDGE
>> + Â Â Â Â Â Â Â Â Â Â orig_source = iph->saddr;
>> +#endif
>> Â Â Â Â Â Â Â Â Â Â Â iph = ip_hdr(skb);
>> Â Â Â Â Â Â Â Â Â Â Â skb->protocol = eth_type_trans(skb, tunnel->dev);
>> Â Â Â Â Â Â Â Â Â Â Â skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
>> +#ifdef CONFIG_NET_IPGRE_BRIDGE
>> + Â Â Â Â Â Â Â Â Â Â if (ipv4_is_multicast(tunnel->parms.iph.daddr)) {
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â tethhdr = eth_hdr(skb);
>
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â if ((tethhdr->h_source[0]&1) == 0) {
>
> Â Â Â Âif (!is_multicast_ether_addr(tethhdr->h_source)) ?
>
fixed

>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â head = &tunnel->hash[
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ipgre_tap_bridge_hash(
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tethhdr->h_source)];
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â entry = ipgre_tap_bridge_find(head,
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tethhdr->h_source);
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (likely(entry)) {
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â entry->raddr = orig_source;
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â entry->ageing_timer = jiffies;
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } else {
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â spin_lock(&tunnel->hash_lock);
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (!ipgre_tap_bridge_find(head,
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tethhdr->h_source))
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ipgre_tap_bridge_create(
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âhead,
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âorig_source,
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âtethhdr->h_source,
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âtunnel->dev);
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â spin_unlock(&tunnel->hash_lock);
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
>> + Â Â Â Â Â Â Â Â Â Â }
>> +#endif
>> Â Â Â Â Â Â Â }
>>
>> Â Â Â Â Â Â Â tstats = this_cpu_ptr(tunnel->dev->tstats);
>> @@ -716,7 +949,17 @@ static netdev_tx_t ipgre_tunnel_xmit(str
>> Â Â Â Â Â Â Â tiph = &tunnel->parms.iph;
>> Â Â Â }
>>
>> +#ifdef CONFIG_NET_IPGRE_BRIDGE
>> + Â Â if ((dev->type == ARPHRD_ETHER) && ipv4_is_multicast(
>
> please format like this :
>
> Â Â Â Âif ((dev->type == ARPHRD_ETHER) &&
> Â Â Â Â Â Âipv4_is_multicast(tunnel->parms.iph.daddr))
>
fixed

>> + Â Â Â Â Â Â tunnel->parms.iph.daddr))
>> + Â Â Â Â Â Â dst = ipgre_tap_bridge_get_raddr(tunnel,
>> + Â Â Â Â Â Â Â Â Â Â ((struct ethhdr *)skb->data)->h_dest);
>> + Â Â if (dst == 0)
>> + Â Â Â Â Â Â dst = tiph->daddr;
>> + Â Â if (dst == 0) {
>> +#else
>> Â Â Â if ((dst = tiph->daddr) == 0) {
>> +#endif
>> Â Â Â Â Â Â Â /* NBMA tunnel */
>>
>> Â Â Â Â Â Â Â if (skb_dst(skb) == NULL) {
>> @@ -1209,6 +1452,16 @@ static int ipgre_open(struct net_device
>> Â Â Â Â Â Â Â Â Â Â Â return -EADDRNOTAVAIL;
>> Â Â Â Â Â Â Â t->mlink = dev->ifindex;
>> Â Â Â Â Â Â Â ip_mc_inc_group(__in_dev_get_rtnl(dev), t->parms.iph.daddr);
>> +#ifdef CONFIG_NET_IPGRE_BRIDGE
>> + Â Â Â Â Â Â if (t->dev->type == ARPHRD_ETHER) {
>> + Â Â Â Â Â Â Â Â Â Â INIT_HLIST_HEAD(t->hash);
>> + Â Â Â Â Â Â Â Â Â Â spin_lock_init(&t->hash_lock);
>> + Â Â Â Â Â Â Â Â Â Â t->ageing_time = 300 * HZ;
>> + Â Â Â Â Â Â Â Â Â Â setup_timer(&t->gc_timer, ipgre_tap_bridge_cleanup,
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â (unsigned long) t);
>> + Â Â Â Â Â Â Â Â Â Â mod_timer(&t->gc_timer, jiffies + t->ageing_time);
>
>
>> + Â Â Â Â Â Â }
>> +#endif
>> Â Â Â }
>> Â Â Â return 0;
>> Â}
>> @@ -1219,6 +1472,12 @@ static int ipgre_close(struct net_device
>>
>> Â Â Â if (ipv4_is_multicast(t->parms.iph.daddr) && t->mlink) {
>> Â Â Â Â Â Â Â struct in_device *in_dev;
>> +#ifdef CONFIG_NET_IPGRE_BRIDGE
>> + Â Â Â Â Â Â if (t->dev->type == ARPHRD_ETHER) {
>> + Â Â Â Â Â Â Â Â Â Â ipgre_tap_bridge_flush(t);
>> + Â Â Â Â Â Â Â Â Â Â del_timer_sync(&t->gc_timer);
>> + Â Â Â Â Â Â }
>> +#endif
>> Â Â Â Â Â Â Â in_dev = inetdev_by_index(dev_net(dev), t->mlink);
>> Â Â Â Â Â Â Â if (in_dev)
>> Â Â Â Â Â Â Â Â Â Â Â ip_mc_dec_group(in_dev, t->parms.iph.daddr);
>> @@ -1341,6 +1600,12 @@ static int __net_init ipgre_init_net(str
>> Â Â Â struct ipgre_net *ign = net_generic(net, ipgre_net_id);
>> Â Â Â int err;
>>
>> +#ifdef CONFIG_NET_IPGRE_BRIDGE
>> + Â Â err = ipgre_tap_bridge_init();
>> + Â Â if (err)
>> + Â Â Â Â Â Â goto err_out;
>> +#endif
>> +
>> Â Â Â ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel), "gre0",
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âipgre_tunnel_setup);
>> Â Â Â if (!ign->fb_tunnel_dev) {
>> @@ -1362,6 +1627,10 @@ static int __net_init ipgre_init_net(str
>> Âerr_reg_dev:
>> Â Â Â ipgre_dev_free(ign->fb_tunnel_dev);
>> Âerr_alloc_dev:
>> +#ifdef CONFIG_NET_IPGRE_BRIDGE
>> + Â Â ipgre_tap_bridge_fini();
>> +err_out:
>> +#endif
>> Â Â Â return err;
>> Â}
>>
>> @@ -1375,6 +1644,9 @@ static void __net_exit ipgre_exit_net(st
>> Â Â Â ipgre_destroy_tunnels(ign, &list);
>> Â Â Â unregister_netdevice_many(&list);
>> Â Â Â rtnl_unlock();
>> +#ifdef CONFIG_NET_IPGRE_BRIDGE
>> + Â Â ipgre_tap_bridge_fini();
>> +#endif
>> Â}
>>
>> Âstatic struct pernet_operations ipgre_net_ops = {
>>
>
>



--
Stefan Gula
CCNP, CCIP
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/