Commit 37f352b5 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller

inet_diag: Move byte-code finding up the call-stack

Current code calculates it at fixed offset. This offset will change, so
move the BC calculation upper to make the further patching simpler.
Signed-off-by: default avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8d34172d
...@@ -488,15 +488,13 @@ static int inet_diag_bc_audit(const void *bytecode, int bytecode_len) ...@@ -488,15 +488,13 @@ static int inet_diag_bc_audit(const void *bytecode, int bytecode_len)
static int inet_csk_diag_dump(struct sock *sk, static int inet_csk_diag_dump(struct sock *sk,
struct sk_buff *skb, struct sk_buff *skb,
struct netlink_callback *cb) struct netlink_callback *cb,
const struct nlattr *bc)
{ {
struct inet_diag_req *r = NLMSG_DATA(cb->nlh); struct inet_diag_req *r = NLMSG_DATA(cb->nlh);
if (nlmsg_attrlen(cb->nlh, sizeof(*r))) { if (bc != NULL) {
struct inet_diag_entry entry; struct inet_diag_entry entry;
const struct nlattr *bc = nlmsg_find_attr(cb->nlh,
sizeof(*r),
INET_DIAG_REQ_BYTECODE);
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
entry.family = sk->sk_family; entry.family = sk->sk_family;
...@@ -527,15 +525,13 @@ static int inet_csk_diag_dump(struct sock *sk, ...@@ -527,15 +525,13 @@ static int inet_csk_diag_dump(struct sock *sk,
static int inet_twsk_diag_dump(struct inet_timewait_sock *tw, static int inet_twsk_diag_dump(struct inet_timewait_sock *tw,
struct sk_buff *skb, struct sk_buff *skb,
struct netlink_callback *cb) struct netlink_callback *cb,
const struct nlattr *bc)
{ {
struct inet_diag_req *r = NLMSG_DATA(cb->nlh); struct inet_diag_req *r = NLMSG_DATA(cb->nlh);
if (nlmsg_attrlen(cb->nlh, sizeof(*r))) { if (bc != NULL) {
struct inet_diag_entry entry; struct inet_diag_entry entry;
const struct nlattr *bc = nlmsg_find_attr(cb->nlh,
sizeof(*r),
INET_DIAG_REQ_BYTECODE);
entry.family = tw->tw_family; entry.family = tw->tw_family;
#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
...@@ -616,13 +612,13 @@ static int inet_diag_fill_req(struct sk_buff *skb, struct sock *sk, ...@@ -616,13 +612,13 @@ static int inet_diag_fill_req(struct sk_buff *skb, struct sock *sk,
} }
static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk, static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk,
struct netlink_callback *cb) struct netlink_callback *cb,
const struct nlattr *bc)
{ {
struct inet_diag_entry entry; struct inet_diag_entry entry;
struct inet_diag_req *r = NLMSG_DATA(cb->nlh); struct inet_diag_req *r = NLMSG_DATA(cb->nlh);
struct inet_connection_sock *icsk = inet_csk(sk); struct inet_connection_sock *icsk = inet_csk(sk);
struct listen_sock *lopt; struct listen_sock *lopt;
const struct nlattr *bc = NULL;
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
int j, s_j; int j, s_j;
int reqnum, s_reqnum; int reqnum, s_reqnum;
...@@ -642,9 +638,7 @@ static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk, ...@@ -642,9 +638,7 @@ static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk,
if (!lopt || !lopt->qlen) if (!lopt || !lopt->qlen)
goto out; goto out;
if (nlmsg_attrlen(cb->nlh, sizeof(*r))) { if (bc != NULL) {
bc = nlmsg_find_attr(cb->nlh, sizeof(*r),
INET_DIAG_REQ_BYTECODE);
entry.sport = inet->inet_num; entry.sport = inet->inet_num;
entry.userlocks = sk->sk_userlocks; entry.userlocks = sk->sk_userlocks;
} }
...@@ -708,6 +702,10 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -708,6 +702,10 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
struct inet_diag_req *r = NLMSG_DATA(cb->nlh); struct inet_diag_req *r = NLMSG_DATA(cb->nlh);
const struct inet_diag_handler *handler; const struct inet_diag_handler *handler;
struct inet_hashinfo *hashinfo; struct inet_hashinfo *hashinfo;
const struct nlattr *bc = NULL;
if (nlmsg_attrlen(cb->nlh, sizeof(struct inet_diag_req)))
bc = nlmsg_find_attr(cb->nlh, sizeof(*r), INET_DIAG_REQ_BYTECODE);
handler = inet_diag_lock_handler(cb->nlh->nlmsg_type); handler = inet_diag_lock_handler(cb->nlh->nlmsg_type);
if (IS_ERR(handler)) if (IS_ERR(handler))
...@@ -747,7 +745,7 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -747,7 +745,7 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
cb->args[3] > 0) cb->args[3] > 0)
goto syn_recv; goto syn_recv;
if (inet_csk_diag_dump(sk, skb, cb) < 0) { if (inet_csk_diag_dump(sk, skb, cb, bc) < 0) {
spin_unlock_bh(&ilb->lock); spin_unlock_bh(&ilb->lock);
goto done; goto done;
} }
...@@ -756,7 +754,7 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -756,7 +754,7 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
if (!(r->idiag_states & TCPF_SYN_RECV)) if (!(r->idiag_states & TCPF_SYN_RECV))
goto next_listen; goto next_listen;
if (inet_diag_dump_reqs(skb, sk, cb) < 0) { if (inet_diag_dump_reqs(skb, sk, cb, bc) < 0) {
spin_unlock_bh(&ilb->lock); spin_unlock_bh(&ilb->lock);
goto done; goto done;
} }
...@@ -809,7 +807,7 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -809,7 +807,7 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
if (r->id.idiag_dport != inet->inet_dport && if (r->id.idiag_dport != inet->inet_dport &&
r->id.idiag_dport) r->id.idiag_dport)
goto next_normal; goto next_normal;
if (inet_csk_diag_dump(sk, skb, cb) < 0) { if (inet_csk_diag_dump(sk, skb, cb, bc) < 0) {
spin_unlock_bh(lock); spin_unlock_bh(lock);
goto done; goto done;
} }
...@@ -831,7 +829,7 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -831,7 +829,7 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
if (r->id.idiag_dport != tw->tw_dport && if (r->id.idiag_dport != tw->tw_dport &&
r->id.idiag_dport) r->id.idiag_dport)
goto next_dying; goto next_dying;
if (inet_twsk_diag_dump(tw, skb, cb) < 0) { if (inet_twsk_diag_dump(tw, skb, cb, bc) < 0) {
spin_unlock_bh(lock); spin_unlock_bh(lock);
goto done; goto done;
} }
......
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