| To: | mk@xxxxxxxxxxxxxx |
|---|---|
| Subject: | Re: [PATCH] xfrm ip6ip6 (revised) |
| From: | "David S. Miller" <davem@xxxxxxxxxx> |
| Date: | Fri, 13 Jun 2003 12:19:58 -0700 (PDT) |
| Cc: | jmorris@xxxxxxxxxxxxxxxx, kuznet@xxxxxxxxxxxxx, netdev@xxxxxxxxxxx, usagi@xxxxxxxxxxxxxx |
| In-reply-to: | <20030613.120702.71089628.davem@xxxxxxxxxx> |
| References: | <20030601.013040.116362760.davem@xxxxxxxxxx> <87smqerml5.wl@xxxxxxxxxx> <20030613.120702.71089628.davem@xxxxxxxxxx> |
| Sender: | netdev-bounce@xxxxxxxxxxx |
From: "David S. Miller" <davem@xxxxxxxxxx>
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;
}
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [PATCH] xfrm ip6ip6 (revised), David S. Miller |
|---|---|
| Next by Date: | [patch] IPV6: Refcount leaks in udpv6_connect(), Ville Nuorvala |
| Previous by Thread: | Re: [PATCH] xfrm ip6ip6 (revised), David S. Miller |
| Next by Thread: | Re: [PATCH] xfrm ip6ip6, David S. Miller |
| Indexes: | [Date] [Thread] [Top] [All Lists] |