Herbert Xu a écrit :
On Tue, Mar 14, 2006 at 07:23:05AM +0100, Eric Dumazet wrote:
Hum, but then we need a new macro or prototype, because n->sp is not valid

n->sp = secpath_get(skb->sp);

would still miscompile, even if secpath_get() is a no-op

How about just leaving sp in the structure unconditionally?

Cheers,

Well, the point of this patch is to shrink a little bit 'struct sk_buff' :)

In this second try, I added a secpath_copy() helper, so that CONFIG_XFRM test is done in include/net/xfrm.h file

[PATCH] [NET] : get rid of 'struct sec_path *' in sk_buff if ! CONFIG_XFRM

There is a strange glitch about secpath_put() and secpath_get() calls.

secpath_put() is called from __kfree_skb() only if CONFIG_XFRM is defined.

secpath_get() is called from skb_clone() and copy_skb_header() if CONFIG_INET is defined (!!!)

I think the intention was to use CONFIG_XFRM everywhere ?

If yes, we can save a 'struct sec_path' pointer from 'struct sk_buff' if ! CONFIG_XFRM

Signed-off-by: Eric Dumazet <[EMAIL PROTECTED]>
--- a/include/net/xfrm.h        2006-03-14 08:23:19.000000000 +0100
+++ b/include/net/xfrm.h        2006-03-14 08:26:38.000000000 +0100
@@ -635,6 +635,14 @@
        return sp;
 }
 
+static inline void
+secpath_copy(struct sk_buff *dst, const struct sk_buff *src)
+{
+#ifdef CONFIG_XFRM
+       dst->sp = secpath_get(src->sp);
+#endif
+}
+
 extern void __secpath_destroy(struct sec_path *sp);
 
 static inline void
--- a/include/linux/skbuff.h    2006-03-13 18:30:21.000000000 +0100
+++ b/include/linux/skbuff.h    2006-03-13 18:38:27.000000000 +0100
@@ -243,7 +243,9 @@
        } mac;
 
        struct  dst_entry       *dst;
+#ifdef CONFIG_XFRM
        struct  sec_path        *sp;
+#endif
 
        /*
         * This is the control buffer. It is free to use for every
--- a/net/core/skbuff.c 2006-03-13 18:31:03.000000000 +0100
+++ b/net/core/skbuff.c 2006-03-14 08:24:33.000000000 +0100
@@ -415,10 +415,7 @@
        C(mac);
        C(dst);
        dst_clone(skb->dst);
-       C(sp);
-#ifdef CONFIG_INET
-       secpath_get(skb->sp);
-#endif
+       secpath_copy(n, skb);
        memcpy(n->cb, skb->cb, sizeof(skb->cb));
        C(len);
        C(data_len);
@@ -483,9 +480,7 @@
        new->priority   = old->priority;
        new->protocol   = old->protocol;
        new->dst        = dst_clone(old->dst);
-#ifdef CONFIG_INET
-       new->sp         = secpath_get(old->sp);
-#endif
+       secpath_copy(new, old);
        new->h.raw      = old->h.raw + offset;
        new->nh.raw     = old->nh.raw + offset;
        new->mac.raw    = old->mac.raw + offset;

Reply via email to