diff options
author | Pavel Emelyanov <xemul@parallels.com> | 2011-12-06 02:57:26 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-12-06 13:58:01 -0500 |
commit | 37f352b5e3e89337f7a9a3a90250b5dde3c5f40d (patch) | |
tree | b7a6b0528e7715b08741d16ab2fd9102da99ad21 /net | |
parent | 8d34172dfdb762a306cdf58b547aa10d798622ec (diff) |
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: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/inet_diag.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index eb6bdfa9480c..7aad6ad24dda 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c | |||
@@ -488,15 +488,13 @@ static int inet_diag_bc_audit(const void *bytecode, int bytecode_len) | |||
488 | 488 | ||
489 | static int inet_csk_diag_dump(struct sock *sk, | 489 | static int inet_csk_diag_dump(struct sock *sk, |
490 | struct sk_buff *skb, | 490 | struct sk_buff *skb, |
491 | struct netlink_callback *cb) | 491 | struct netlink_callback *cb, |
492 | const struct nlattr *bc) | ||
492 | { | 493 | { |
493 | struct inet_diag_req *r = NLMSG_DATA(cb->nlh); | 494 | struct inet_diag_req *r = NLMSG_DATA(cb->nlh); |
494 | 495 | ||
495 | if (nlmsg_attrlen(cb->nlh, sizeof(*r))) { | 496 | if (bc != NULL) { |
496 | struct inet_diag_entry entry; | 497 | struct inet_diag_entry entry; |
497 | const struct nlattr *bc = nlmsg_find_attr(cb->nlh, | ||
498 | sizeof(*r), | ||
499 | INET_DIAG_REQ_BYTECODE); | ||
500 | struct inet_sock *inet = inet_sk(sk); | 498 | struct inet_sock *inet = inet_sk(sk); |
501 | 499 | ||
502 | entry.family = sk->sk_family; | 500 | entry.family = sk->sk_family; |
@@ -527,15 +525,13 @@ static int inet_csk_diag_dump(struct sock *sk, | |||
527 | 525 | ||
528 | static int inet_twsk_diag_dump(struct inet_timewait_sock *tw, | 526 | static int inet_twsk_diag_dump(struct inet_timewait_sock *tw, |
529 | struct sk_buff *skb, | 527 | struct sk_buff *skb, |
530 | struct netlink_callback *cb) | 528 | struct netlink_callback *cb, |
529 | const struct nlattr *bc) | ||
531 | { | 530 | { |
532 | struct inet_diag_req *r = NLMSG_DATA(cb->nlh); | 531 | struct inet_diag_req *r = NLMSG_DATA(cb->nlh); |
533 | 532 | ||
534 | if (nlmsg_attrlen(cb->nlh, sizeof(*r))) { | 533 | if (bc != NULL) { |
535 | struct inet_diag_entry entry; | 534 | struct inet_diag_entry entry; |
536 | const struct nlattr *bc = nlmsg_find_attr(cb->nlh, | ||
537 | sizeof(*r), | ||
538 | INET_DIAG_REQ_BYTECODE); | ||
539 | 535 | ||
540 | entry.family = tw->tw_family; | 536 | entry.family = tw->tw_family; |
541 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 537 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
@@ -616,13 +612,13 @@ nlmsg_failure: | |||
616 | } | 612 | } |
617 | 613 | ||
618 | static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk, | 614 | static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk, |
619 | struct netlink_callback *cb) | 615 | struct netlink_callback *cb, |
616 | const struct nlattr *bc) | ||
620 | { | 617 | { |
621 | struct inet_diag_entry entry; | 618 | struct inet_diag_entry entry; |
622 | struct inet_diag_req *r = NLMSG_DATA(cb->nlh); | 619 | struct inet_diag_req *r = NLMSG_DATA(cb->nlh); |
623 | struct inet_connection_sock *icsk = inet_csk(sk); | 620 | struct inet_connection_sock *icsk = inet_csk(sk); |
624 | struct listen_sock *lopt; | 621 | struct listen_sock *lopt; |
625 | const struct nlattr *bc = NULL; | ||
626 | struct inet_sock *inet = inet_sk(sk); | 622 | struct inet_sock *inet = inet_sk(sk); |
627 | int j, s_j; | 623 | int j, s_j; |
628 | int reqnum, s_reqnum; | 624 | int reqnum, s_reqnum; |
@@ -642,9 +638,7 @@ static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk, | |||
642 | if (!lopt || !lopt->qlen) | 638 | if (!lopt || !lopt->qlen) |
643 | goto out; | 639 | goto out; |
644 | 640 | ||
645 | if (nlmsg_attrlen(cb->nlh, sizeof(*r))) { | 641 | if (bc != NULL) { |
646 | bc = nlmsg_find_attr(cb->nlh, sizeof(*r), | ||
647 | INET_DIAG_REQ_BYTECODE); | ||
648 | entry.sport = inet->inet_num; | 642 | entry.sport = inet->inet_num; |
649 | entry.userlocks = sk->sk_userlocks; | 643 | entry.userlocks = sk->sk_userlocks; |
650 | } | 644 | } |
@@ -708,6 +702,10 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
708 | struct inet_diag_req *r = NLMSG_DATA(cb->nlh); | 702 | struct inet_diag_req *r = NLMSG_DATA(cb->nlh); |
709 | const struct inet_diag_handler *handler; | 703 | const struct inet_diag_handler *handler; |
710 | struct inet_hashinfo *hashinfo; | 704 | struct inet_hashinfo *hashinfo; |
705 | const struct nlattr *bc = NULL; | ||
706 | |||
707 | if (nlmsg_attrlen(cb->nlh, sizeof(struct inet_diag_req))) | ||
708 | bc = nlmsg_find_attr(cb->nlh, sizeof(*r), INET_DIAG_REQ_BYTECODE); | ||
711 | 709 | ||
712 | handler = inet_diag_lock_handler(cb->nlh->nlmsg_type); | 710 | handler = inet_diag_lock_handler(cb->nlh->nlmsg_type); |
713 | if (IS_ERR(handler)) | 711 | if (IS_ERR(handler)) |
@@ -747,7 +745,7 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
747 | cb->args[3] > 0) | 745 | cb->args[3] > 0) |
748 | goto syn_recv; | 746 | goto syn_recv; |
749 | 747 | ||
750 | if (inet_csk_diag_dump(sk, skb, cb) < 0) { | 748 | if (inet_csk_diag_dump(sk, skb, cb, bc) < 0) { |
751 | spin_unlock_bh(&ilb->lock); | 749 | spin_unlock_bh(&ilb->lock); |
752 | goto done; | 750 | goto done; |
753 | } | 751 | } |
@@ -756,7 +754,7 @@ syn_recv: | |||
756 | if (!(r->idiag_states & TCPF_SYN_RECV)) | 754 | if (!(r->idiag_states & TCPF_SYN_RECV)) |
757 | goto next_listen; | 755 | goto next_listen; |
758 | 756 | ||
759 | if (inet_diag_dump_reqs(skb, sk, cb) < 0) { | 757 | if (inet_diag_dump_reqs(skb, sk, cb, bc) < 0) { |
760 | spin_unlock_bh(&ilb->lock); | 758 | spin_unlock_bh(&ilb->lock); |
761 | goto done; | 759 | goto done; |
762 | } | 760 | } |
@@ -809,7 +807,7 @@ skip_listen_ht: | |||
809 | if (r->id.idiag_dport != inet->inet_dport && | 807 | if (r->id.idiag_dport != inet->inet_dport && |
810 | r->id.idiag_dport) | 808 | r->id.idiag_dport) |
811 | goto next_normal; | 809 | goto next_normal; |
812 | if (inet_csk_diag_dump(sk, skb, cb) < 0) { | 810 | if (inet_csk_diag_dump(sk, skb, cb, bc) < 0) { |
813 | spin_unlock_bh(lock); | 811 | spin_unlock_bh(lock); |
814 | goto done; | 812 | goto done; |
815 | } | 813 | } |
@@ -831,7 +829,7 @@ next_normal: | |||
831 | if (r->id.idiag_dport != tw->tw_dport && | 829 | if (r->id.idiag_dport != tw->tw_dport && |
832 | r->id.idiag_dport) | 830 | r->id.idiag_dport) |
833 | goto next_dying; | 831 | goto next_dying; |
834 | if (inet_twsk_diag_dump(tw, skb, cb) < 0) { | 832 | if (inet_twsk_diag_dump(tw, skb, cb, bc) < 0) { |
835 | spin_unlock_bh(lock); | 833 | spin_unlock_bh(lock); |
836 | goto done; | 834 | goto done; |
837 | } | 835 | } |