Commit 30cd9e65 authored by Harald Welte's avatar Harald Welte Committed by David S. Miller

[NET]: Fix NLM_F_MULTI in tcp_diag and xfrm_user

Signed-off-by: default avatarHarald Welte <laforge@netfilter.org>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ac25f630
...@@ -53,7 +53,7 @@ static struct sock *tcpnl; ...@@ -53,7 +53,7 @@ static struct sock *tcpnl;
RTA_DATA(rta); }) RTA_DATA(rta); })
static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk, 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 inet_opt *inet = inet_sk(sk);
struct tcp_opt *tp = tcp_sk(sk); struct tcp_opt *tp = tcp_sk(sk);
...@@ -65,6 +65,7 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk, ...@@ -65,6 +65,7 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
unsigned char *b = skb->tail; unsigned char *b = skb->tail;
nlh = NLMSG_PUT(skb, pid, seq, TCPDIAG_GETSOCK, sizeof(*r)); nlh = NLMSG_PUT(skb, pid, seq, TCPDIAG_GETSOCK, sizeof(*r));
nlh->nlmsg_flags = nlmsg_flags;
r = NLMSG_DATA(nlh); r = NLMSG_DATA(nlh);
if (sk->sk_state != TCP_TIME_WAIT) { if (sk->sk_state != TCP_TIME_WAIT) {
if (ext & (1<<(TCPDIAG_MEMINFO-1))) if (ext & (1<<(TCPDIAG_MEMINFO-1)))
...@@ -236,7 +237,7 @@ static int tcpdiag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh) ...@@ -236,7 +237,7 @@ static int tcpdiag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh)
if (tcpdiag_fill(rep, sk, req->tcpdiag_ext, if (tcpdiag_fill(rep, sk, req->tcpdiag_ext,
NETLINK_CB(in_skb).pid, NETLINK_CB(in_skb).pid,
nlh->nlmsg_seq) <= 0) nlh->nlmsg_seq, 0) <= 0)
BUG(); BUG();
err = netlink_unicast(tcpnl, rep, NETLINK_CB(in_skb).pid, MSG_DONTWAIT); err = netlink_unicast(tcpnl, rep, NETLINK_CB(in_skb).pid, MSG_DONTWAIT);
...@@ -442,7 +443,7 @@ static int tcpdiag_dump_sock(struct sk_buff *skb, struct sock *sk, ...@@ -442,7 +443,7 @@ static int tcpdiag_dump_sock(struct sk_buff *skb, struct sock *sk,
} }
return tcpdiag_fill(skb, sk, r->tcpdiag_ext, NETLINK_CB(cb->skb).pid, 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, static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk,
...@@ -456,6 +457,7 @@ static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk, ...@@ -456,6 +457,7 @@ static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk,
long tmo; long tmo;
nlh = NLMSG_PUT(skb, pid, seq, TCPDIAG_GETSOCK, sizeof(*r)); nlh = NLMSG_PUT(skb, pid, seq, TCPDIAG_GETSOCK, sizeof(*r));
nlh->nlmsg_flags = NLM_F_MULTI;
r = NLMSG_DATA(nlh); r = NLMSG_DATA(nlh);
r->tcpdiag_family = sk->sk_family; r->tcpdiag_family = sk->sk_family;
......
...@@ -332,6 +332,7 @@ struct xfrm_dump_info { ...@@ -332,6 +332,7 @@ struct xfrm_dump_info {
struct sk_buff *in_skb; struct sk_buff *in_skb;
struct sk_buff *out_skb; struct sk_buff *out_skb;
u32 nlmsg_seq; u32 nlmsg_seq;
u16 nlmsg_flags;
int start_idx; int start_idx;
int this_idx; int this_idx;
}; };
...@@ -351,7 +352,7 @@ static int dump_one_state(struct xfrm_state *x, int count, void *ptr) ...@@ -351,7 +352,7 @@ static int dump_one_state(struct xfrm_state *x, int count, void *ptr)
nlh = NLMSG_PUT(skb, NETLINK_CB(in_skb).pid, nlh = NLMSG_PUT(skb, NETLINK_CB(in_skb).pid,
sp->nlmsg_seq, sp->nlmsg_seq,
XFRM_MSG_NEWSA, sizeof(*p)); XFRM_MSG_NEWSA, sizeof(*p));
nlh->nlmsg_flags = 0; nlh->nlmsg_flags = sp->nlmsg_flags;
p = NLMSG_DATA(nlh); p = NLMSG_DATA(nlh);
copy_to_user_state(x, p); copy_to_user_state(x, p);
...@@ -386,6 +387,7 @@ static int xfrm_dump_sa(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -386,6 +387,7 @@ static int xfrm_dump_sa(struct sk_buff *skb, struct netlink_callback *cb)
info.in_skb = cb->skb; info.in_skb = cb->skb;
info.out_skb = skb; info.out_skb = skb;
info.nlmsg_seq = cb->nlh->nlmsg_seq; info.nlmsg_seq = cb->nlh->nlmsg_seq;
info.nlmsg_flags = NLM_F_MULTI;
info.this_idx = 0; info.this_idx = 0;
info.start_idx = cb->args[0]; info.start_idx = cb->args[0];
(void) xfrm_state_walk(IPSEC_PROTO_ANY, dump_one_state, &info); (void) xfrm_state_walk(IPSEC_PROTO_ANY, dump_one_state, &info);
...@@ -408,6 +410,7 @@ static struct sk_buff *xfrm_state_netlink(struct sk_buff *in_skb, ...@@ -408,6 +410,7 @@ static struct sk_buff *xfrm_state_netlink(struct sk_buff *in_skb,
info.in_skb = in_skb; info.in_skb = in_skb;
info.out_skb = skb; info.out_skb = skb;
info.nlmsg_seq = seq; info.nlmsg_seq = seq;
info.nlmsg_flags = 0;
info.this_idx = info.start_idx = 0; info.this_idx = info.start_idx = 0;
if (dump_one_state(x, 0, &info)) { if (dump_one_state(x, 0, &info)) {
...@@ -743,7 +746,7 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr ...@@ -743,7 +746,7 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr
sp->nlmsg_seq, sp->nlmsg_seq,
XFRM_MSG_NEWPOLICY, sizeof(*p)); XFRM_MSG_NEWPOLICY, sizeof(*p));
p = NLMSG_DATA(nlh); p = NLMSG_DATA(nlh);
nlh->nlmsg_flags = 0; nlh->nlmsg_flags = sp->nlmsg_flags;
copy_to_user_policy(xp, p, dir); copy_to_user_policy(xp, p, dir);
if (copy_to_user_tmpl(xp, skb) < 0) if (copy_to_user_tmpl(xp, skb) < 0)
...@@ -766,6 +769,7 @@ static int xfrm_dump_policy(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -766,6 +769,7 @@ static int xfrm_dump_policy(struct sk_buff *skb, struct netlink_callback *cb)
info.in_skb = cb->skb; info.in_skb = cb->skb;
info.out_skb = skb; info.out_skb = skb;
info.nlmsg_seq = cb->nlh->nlmsg_seq; info.nlmsg_seq = cb->nlh->nlmsg_seq;
info.nlmsg_flags = NLM_F_MULTI;
info.this_idx = 0; info.this_idx = 0;
info.start_idx = cb->args[0]; info.start_idx = cb->args[0];
(void) xfrm_policy_walk(dump_one_policy, &info); (void) xfrm_policy_walk(dump_one_policy, &info);
...@@ -789,6 +793,7 @@ static struct sk_buff *xfrm_policy_netlink(struct sk_buff *in_skb, ...@@ -789,6 +793,7 @@ static struct sk_buff *xfrm_policy_netlink(struct sk_buff *in_skb,
info.in_skb = in_skb; info.in_skb = in_skb;
info.out_skb = skb; info.out_skb = skb;
info.nlmsg_seq = seq; info.nlmsg_seq = seq;
info.nlmsg_flags = 0;
info.this_idx = info.start_idx = 0; info.this_idx = info.start_idx = 0;
if (dump_one_policy(xp, dir, 0, &info) < 0) { if (dump_one_policy(xp, dir, 0, &info) < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment