summaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-01-27 14:58:42 -0800
committerDavid S. Miller <davem@davemloft.net>2011-01-27 14:59:31 -0800
commit065825402c058f4a123ddc53dbbe864cc5caaf64 (patch)
tree7d0d5122a5315c5850a0b01ed7349e9eebf794e2 /net/ipv4/route.c
parent1397e171f143878dd16ad5f8c99f7b9440cc8911 (diff)
downloadop-kernel-dev-065825402c058f4a123ddc53dbbe864cc5caaf64.zip
op-kernel-dev-065825402c058f4a123ddc53dbbe864cc5caaf64.tar.gz
net: Store ipv4/ipv6 COW'd metrics in inetpeer cache.
Please note that the IPSEC dst entry metrics keep using the generic metrics COW'ing mechanism using kmalloc/kfree. This gives the IPSEC routes an opportunity to use metrics which are unique to their encapsulated paths. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r--net/ipv4/route.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 980030d4..68cee35 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -154,25 +154,30 @@ static void ipv4_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
static u32 *ipv4_cow_metrics(struct dst_entry *dst, unsigned long old)
{
- u32 *p = kmalloc(sizeof(u32) * RTAX_MAX, GFP_ATOMIC);
+ struct rtable *rt = (struct rtable *) dst;
+ struct inet_peer *peer;
+ u32 *p = NULL;
+
+ if (!rt->peer)
+ rt_bind_peer(rt, 1);
- if (p) {
+ peer = rt->peer;
+ if (peer) {
u32 *old_p = __DST_METRICS_PTR(old);
unsigned long prev, new;
- memcpy(p, old_p, sizeof(u32) * RTAX_MAX);
+ p = peer->metrics;
+ if (inet_metrics_new(peer))
+ memcpy(p, old_p, sizeof(u32) * RTAX_MAX);
new = (unsigned long) p;
prev = cmpxchg(&dst->_metrics, old, new);
if (prev != old) {
- kfree(p);
p = __DST_METRICS_PTR(prev);
if (prev & DST_METRICS_READ_ONLY)
p = NULL;
} else {
- struct rtable *rt = (struct rtable *) dst;
-
if (rt->fi) {
fib_info_put(rt->fi);
rt->fi = NULL;
@@ -1753,7 +1758,6 @@ static void ipv4_dst_destroy(struct dst_entry *dst)
struct rtable *rt = (struct rtable *) dst;
struct inet_peer *peer = rt->peer;
- dst_destroy_metrics_generic(dst);
if (rt->fi) {
fib_info_put(rt->fi);
rt->fi = NULL;
OpenPOWER on IntegriCloud