Thread (11 messages) 11 messages, 5 authors, 2003-06-13

Re: [PATCH] xfrm ip6ip6 (revised)

From: David S. Miller <hidden>
Date: 2003-06-13 19:19:58

   From: "David S. Miller" [off-list ref]
   Date: Fri, 13 Jun 2003 12:07:02 -0700 (PDT)

   You need to add refcount to hash table entries, so that SPI can be
   shared by different xfrm6 tunnels with same address.
   
Mitsuru, here is some example code showing what my
idea looks like.  I apologize for not making something
like this for you earlier.

struct v6spi_entry {
	struct v6spi_entry *next;
	struct in6_addr addr;
	u32 spi;
	atomic_t refcnt;
};

u32 spi v6spi_alloc(struct in6_addr *addr)
{
	int h = v6_hashfn(addr);
	struct v6spi_entry *ent;

	for (ent = hash_table[h]; ent; ent = ent->next) {
		if (!ipv6_addr_cmp(addr, &ent->addr)) {
			atomic_inc(&ent->refcnt);
			return ent->spi;
		}
	}
	ent = kmalloc(sizeof(*ent), GFP_ATOMIC);
	ent->spi = alloc_unique_spi();
	ipv6_addr_copy(&ent->addr, addr);
	atomic_set(&ent->refcnt, 1);
	ent->next = hash_table[h];
	hash_table[h] = ent;

	return ent->spi;
}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help