netdev
[Top] [All Lists]

[PATCH 2.6] fix NLM_F_MULTI in tcp_diag and xfrm_user (was Re: BTW)

To: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Subject: [PATCH 2.6] fix NLM_F_MULTI in tcp_diag and xfrm_user (was Re: BTW)
From: Harald Welte <laforge@xxxxxxxxxxxxx>
Date: Wed, 27 Oct 2004 10:51:41 +0200
Cc: davem@xxxxxxxxxxxxx, netdev@xxxxxxxxxxx
In-reply-to: <E1CMjAM-0002aJ-00@xxxxxxxxxxxxxxxxxxxxxxxx>
References: <20041027074307.GT18934@xxxxxxxxxxxxxxxxxxxxxxx> <E1CMjAM-0002aJ-00@xxxxxxxxxxxxxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mutt/1.5.6+20040907i
Sorry for submitting incomplete/stupid patches, but as indicated before,
I'm not familiar with that code at all.

> This doesn't set it for the tw sockets.  So just set it at the top
> of the function instead.

done

> Yuck.  Please put this into xfrm_dump_info.

done.

> And it would be good to fix the other dumper in this file (xfrm_dump_policy)
> as well.

done.


diff -Nru --exclude-from=/sunbeam/home/laforge/scripts/dontdiff 
linux-2.6.9-bk7/net/ipv4/tcp_diag.c 
linux-2.6.9-bk7-netlink_f_multi/net/ipv4/tcp_diag.c
--- linux-2.6.9-bk7/net/ipv4/tcp_diag.c 2004-10-22 18:18:52.000000000 +0200
+++ linux-2.6.9-bk7-netlink_f_multi/net/ipv4/tcp_diag.c 2004-10-27 
10:46:21.677098691 +0200
@@ -108,7 +108,7 @@
 }
 
 static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
-                       int ext, u32 pid, u32 seq)
+                       int ext, u32 pid, u32 seq, u16 nlmsg_flags)
 {
        struct inet_opt *inet = inet_sk(sk);
        struct tcp_opt *tp = tcp_sk(sk);
@@ -120,6 +120,7 @@
        unsigned char    *b = skb->tail;
 
        nlh = NLMSG_PUT(skb, pid, seq, TCPDIAG_GETSOCK, sizeof(*r));
+       nlh->nlmsg_flags = nlmsg_flags;
        r = NLMSG_DATA(nlh);
        if (sk->sk_state != TCP_TIME_WAIT) {
                if (ext & (1<<(TCPDIAG_MEMINFO-1)))
@@ -291,7 +292,7 @@
 
        if (tcpdiag_fill(rep, sk, req->tcpdiag_ext,
                         NETLINK_CB(in_skb).pid,
-                        nlh->nlmsg_seq) <= 0)
+                        nlh->nlmsg_seq, 0) <= 0)
                BUG();
 
        err = netlink_unicast(tcpnl, rep, NETLINK_CB(in_skb).pid, MSG_DONTWAIT);
@@ -497,7 +498,7 @@
        }
 
        return tcpdiag_fill(skb, sk, r->tcpdiag_ext, NETLINK_CB(cb->skb).pid,
-                           cb->nlh->nlmsg_seq);
+                           cb->nlh->nlmsg_seq, NLM_F_MULTI);
 }
 
 static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk,
@@ -511,6 +512,7 @@
        long tmo;
 
        nlh = NLMSG_PUT(skb, pid, seq, TCPDIAG_GETSOCK, sizeof(*r));
+       nlh->nlmsg_flags = NLM_F_MULTI;
        r = NLMSG_DATA(nlh);
 
        r->tcpdiag_family = sk->sk_family;
diff -Nru --exclude-from=/sunbeam/home/laforge/scripts/dontdiff 
linux-2.6.9-bk7/net/xfrm/xfrm_user.c 
linux-2.6.9-bk7-netlink_f_multi/net/xfrm/xfrm_user.c
--- linux-2.6.9-bk7/net/xfrm/xfrm_user.c        2004-10-18 23:54:32.000000000 
+0200
+++ linux-2.6.9-bk7-netlink_f_multi/net/xfrm/xfrm_user.c        2004-10-27 
10:45:09.780597181 +0200
@@ -332,6 +332,7 @@
        struct sk_buff *in_skb;
        struct sk_buff *out_skb;
        u32 nlmsg_seq;
+       u16 nlmsg_flags;
        int start_idx;
        int this_idx;
 };
@@ -351,7 +352,7 @@
        nlh = NLMSG_PUT(skb, NETLINK_CB(in_skb).pid,
                        sp->nlmsg_seq,
                        XFRM_MSG_NEWSA, sizeof(*p));
-       nlh->nlmsg_flags = 0;
+       nlh->nlmsg_flags = sp->nlmsg_flags;
 
        p = NLMSG_DATA(nlh);
        copy_to_user_state(x, p);
@@ -386,6 +387,7 @@
        info.in_skb = cb->skb;
        info.out_skb = skb;
        info.nlmsg_seq = cb->nlh->nlmsg_seq;
+       info.nlmsg_flags = NLM_F_MULTI;
        info.this_idx = 0;
        info.start_idx = cb->args[0];
        (void) xfrm_state_walk(IPSEC_PROTO_ANY, dump_one_state, &info);
@@ -408,6 +410,7 @@
        info.in_skb = in_skb;
        info.out_skb = skb;
        info.nlmsg_seq = seq;
+       info.nlmsg_flags = 0;
        info.this_idx = info.start_idx = 0;
 
        if (dump_one_state(x, 0, &info)) {
@@ -743,7 +746,7 @@
                        sp->nlmsg_seq,
                        XFRM_MSG_NEWPOLICY, sizeof(*p));
        p = NLMSG_DATA(nlh);
-       nlh->nlmsg_flags = 0;
+       nlh->nlmsg_flags = sp->nlmsg_flags;
 
        copy_to_user_policy(xp, p, dir);
        if (copy_to_user_tmpl(xp, skb) < 0)
@@ -766,6 +769,7 @@
        info.in_skb = cb->skb;
        info.out_skb = skb;
        info.nlmsg_seq = cb->nlh->nlmsg_seq;
+       info.nlmsg_flags = NLM_F_MULTI;
        info.this_idx = 0;
        info.start_idx = cb->args[0];
        (void) xfrm_policy_walk(dump_one_policy, &info);
@@ -789,6 +793,7 @@
        info.in_skb = in_skb;
        info.out_skb = skb;
        info.nlmsg_seq = seq;
+       info.nlmsg_flags = 0;
        info.this_idx = info.start_idx = 0;
 
        if (dump_one_policy(xp, dir, 0, &info) < 0) {
-- 
- Harald Welte <laforge@xxxxxxxxxxxxx>             http://www.netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie

Attachment: signature.asc
Description: Digital signature

<Prev in Thread] Current Thread [Next in Thread>