pass dst_ops to gc functions and add a netns pointer in it
Subsystems (4)
cover pass dst_ops to gc functions and add a netns pointer in it
The two following patches do trivial changes to facilitate the implementation of the network namespace in some protocols.
The first one pass the dst_ops as parameter to the gc functions. The second patch just adds a netns pointer field into the dst_ops structure.
PATCH 1/2 dst: pass the dst_ops as parameter to the gc functions
The garbage collection function receive the dst_ops structure as parameter. This is useful for the next incoming patchset because it will need the dst_ops (there will be several instances) and the network namespace pointer (contained in the dst_ops).
The protocols which do not take care of the namespaces will not be impacted by this change (expect for the function signature), they do just ignore the parameter.
--- include/net/dst.h | 2 +- net/core/dst.c | 2 +- net/decnet/dn_route.c | 4 ++-- net/ipv4/route.c | 6 +++--- net/ipv4/xfrm4_policy.c | 2 +- net/ipv6/route.c | 4 ++-- net/ipv6/xfrm6_policy.c | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-)
include/net/dst.h +1 -1
@@ -89,7 +89,7 @@ struct dst_ops__be16 protocol;unsigned gc_thresh; -int (*gc)(void ); +int (*gc)(struct dst_ops *ops);struct dst_entry * (*check)(struct dst_entry *,__u32 cookie);void (*destroy)(struct dst_entry *); void (*ifdown)(struct dst_entry *,
net/core/dst.c +1 -1
@@ -165,7 +165,7 @@ void * dst_alloc(struct dst_ops * ops)struct dst_entry * dst;if (ops->gc &&atomic_read (&ops->entries) > ops->gc_thresh) { -if (ops->gc ()) +if (ops->gc (ops))return NULL ; } dst =kmem_cache_zalloc (ops->kmem_cachep,GFP_ATOMIC );
net/decnet/dn_route.c +2 -2
@@ -107,7 +107,7 @@ static const int dn_rt_mtu_expires = 10static unsigned long dn_rt_deadline; -static int dn_dst_gc (void ); +static int dn_dst_gc (struct dst_ops *ops);static struct dst_entry *dn_dst_check (struct dst_entry *,__u32 );static struct dst_entry *dn_dst_negative_advice (struct dst_entry *);static void dn_dst_link_failure (struct sk_buff *);
@@ -185,7 +185,7 @@ static void dn_dst_check_expire(unsignedmod_timer (&dn_route_timer, now + decnet_dst_gc_interval *HZ ); } -static int dn_dst_gc (void ) +static int dn_dst_gc (struct dst_ops *ops) {struct dn_route *rt, **rtp;int i;
net/ipv4/route.c +3 -3
@@ -154,7 +154,7 @@ static void ipv4_dst_ifdown(struct dststatic struct dst_entry *ipv4_negative_advice (struct dst_entry *dst);static void ipv4_link_failure (struct sk_buff *skb);static void ip_rt_update_pmtu (struct dst_entry *dst,u32 mtu); -static int rt_garbage_collect (void ); +static int rt_garbage_collect (struct dst_ops *ops);static struct dst_ops ipv4_dst_ops = {
@@ -820,7 +820,7 @@ static void rt_secret_rebuild(unsigned land when load increases it reduces to limit cache size. */ -static int rt_garbage_collect (void ) +static int rt_garbage_collect (struct dst_ops *ops) {static unsigned long expire =RT_GC_TIMEOUT ;static unsigned long last_gc;
@@ -1035,7 +1035,7 @@ restart:int saved_int = ip_rt_gc_min_interval; ip_rt_gc_elasticity =1 ; ip_rt_gc_min_interval =0 ; -rt_garbage_collect (); +rt_garbage_collect (&ipv4_dst_ops); ip_rt_gc_min_interval = saved_int; ip_rt_gc_elasticity = saved_elasticity; goto restart;
net/ipv4/xfrm4_policy.c +1 -1
@@ -185,7 +185,7 @@ _decode_session4(struct sk_buff *skb, st fl->fl4_tos = iph->tos; } -static inline int xfrm4_garbage_collect (void ) +static inline int xfrm4_garbage_collect (struct dst_ops *ops) { xfrm4_policy_afinfo.garbage_collect ();return (atomic_read (&xfrm4_dst_ops.entries) > xfrm4_dst_ops.gc_thresh*2 );
net/ipv6/route.c +2 -2
@@ -79,7 +79,7 @@ static struct dst_entry *ip6_negative_adstatic void ip6_dst_destroy (struct dst_entry *);static void ip6_dst_ifdown (struct dst_entry *,struct net_device *dev,int how); -static int ip6_dst_gc (void ); +static int ip6_dst_gc (struct dst_ops *ops);static int ip6_pkt_discard (struct sk_buff *skb);static int ip6_pkt_discard_out (struct sk_buff *skb);
@@ -978,7 +978,7 @@ int ndisc_dst_gc(int *more)return freed; } -static int ip6_dst_gc (void ) +static int ip6_dst_gc (struct dst_ops *ops) {static unsigned expire =30 *HZ ;static unsigned long last_gc;
net/ipv6/xfrm6_policy.c +1 -1
@@ -212,7 +212,7 @@ _decode_session6(struct sk_buff *skb, st } } -static inline int xfrm6_garbage_collect (void ) +static inline int xfrm6_garbage_collect (struct dst_ops *ops) { xfrm6_policy_afinfo.garbage_collect ();return (atomic_read (&xfrm6_dst_ops.entries) > xfrm6_dst_ops.gc_thresh*2 );
Re: [patch 1/2][NETNS][DST] dst: pass the dst_ops as parameter to the gc functions
From: Daniel Lezcano <[email protected]>
Date: Wed, 16 Jan 2008 15:54:17 +0100
Quoted 10 lines
The garbage collection function receive the
dst_opsstructure as parameter. This is useful for the next incoming patchset because it will need thedst_ops(there will be several instances) and the network namespace pointer (contained in thedst_ops).The protocols which do not take care of the namespaces will not be impacted by this change (expect for the function signature), they do just ignore the parameter.
Signed-off-by Daniel Lezcano <[email protected]>
Applied.
PATCH 2/2 add the network namespace pointer in dst_ops
In reply to Daniel LezcanoThe network namespace pointer can be stored into the dst_ops structure. This is usefull when there are multiple instances of the dst_ops for a protocol. When there are no several instances, this field will be never used in the protocol. So there is no impact for the protocols which do implement the network namespaces.
--- include/net/dst.h | 1 + 1 file changed, 1 insertion(+)
include/net/dst.h +1 -0
@@ -102,6 +102,7 @@ struct dst_opsatomic_t entries;struct kmem_cache *kmem_cachep; +struct net *dst_net; };#ifdef __KERNEL__
Re: [patch 2/2][NETNS][DST] add the network namespace pointer in dst_ops
From: Daniel Lezcano <[email protected]>
Date: Wed, 16 Jan 2008 15:54:18 +0100
Quoted 7 lines
The network namespace pointer can be stored into the
dst_opsstructure. This is usefull when there are multiple instances of thedst_opsfor a protocol. When there are no several instances, this field will be never used in the protocol. So there is no impact for the protocols which do implement the network namespaces.Signed-off-by Daniel Lezcano <[email protected]>
Applied, thanks.