aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/pppoe.c22
-rw-r--r--include/net/sock.h23
-rw-r--r--net/dccp/ipv4.c23
-rw-r--r--net/dccp/ipv6.c17
-rw-r--r--net/decnet/dn_nsp_in.c17
5 files changed, 29 insertions, 73 deletions
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index a842ecc60a34..71e303b28646 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -383,8 +383,6 @@ static int pppoe_rcv(struct sk_buff *skb,
383{ 383{
384 struct pppoe_hdr *ph; 384 struct pppoe_hdr *ph;
385 struct pppox_sock *po; 385 struct pppox_sock *po;
386 struct sock *sk;
387 int ret;
388 386
389 if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr))) 387 if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr)))
390 goto drop; 388 goto drop;
@@ -395,24 +393,8 @@ static int pppoe_rcv(struct sk_buff *skb,
395 ph = (struct pppoe_hdr *) skb->nh.raw; 393 ph = (struct pppoe_hdr *) skb->nh.raw;
396 394
397 po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source); 395 po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source);
398 if (!po) 396 if (po != NULL)
399 goto drop; 397 return sk_receive_skb(sk_pppox(po), skb);
400
401 sk = sk_pppox(po);
402 bh_lock_sock(sk);
403
404 /* Socket state is unknown, must put skb into backlog. */
405 if (sock_owned_by_user(sk) != 0) {
406 sk_add_backlog(sk, skb);
407 ret = NET_RX_SUCCESS;
408 } else {
409 ret = pppoe_rcv_core(sk, skb);
410 }
411
412 bh_unlock_sock(sk);
413 sock_put(sk);
414
415 return ret;
416drop: 398drop:
417 kfree_skb(skb); 399 kfree_skb(skb);
418out: 400out:
diff --git a/include/net/sock.h b/include/net/sock.h
index 91d28957dc10..6961700ff3a0 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -926,6 +926,29 @@ static inline void sock_put(struct sock *sk)
926 sk_free(sk); 926 sk_free(sk);
927} 927}
928 928
929static inline int sk_receive_skb(struct sock *sk, struct sk_buff *skb)
930{
931 int rc = NET_RX_SUCCESS;
932
933 if (sk_filter(sk, skb, 0))
934 goto discard_and_relse;
935
936 skb->dev = NULL;
937
938 bh_lock_sock(sk);
939 if (!sock_owned_by_user(sk))
940 rc = sk->sk_backlog_rcv(sk, skb);
941 else
942 sk_add_backlog(sk, skb);
943 bh_unlock_sock(sk);
944out:
945 sock_put(sk);
946 return rc;
947discard_and_relse:
948 kfree_skb(skb);
949 goto out;
950}
951
929/* Detach socket from process context. 952/* Detach socket from process context.
930 * Announce socket dead, detach it from wait queue and inode. 953 * Announce socket dead, detach it from wait queue and inode.
931 * Note that parent inode held reference count on this struct sock, 954 * Note that parent inode held reference count on this struct sock,
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index c363051a7f16..99e8afa7ba1e 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -914,7 +914,6 @@ int dccp_v4_rcv(struct sk_buff *skb)
914{ 914{
915 const struct dccp_hdr *dh; 915 const struct dccp_hdr *dh;
916 struct sock *sk; 916 struct sock *sk;
917 int rc;
918 917
919 /* Step 1: Check header basics: */ 918 /* Step 1: Check header basics: */
920 919
@@ -984,28 +983,10 @@ int dccp_v4_rcv(struct sk_buff *skb)
984 goto do_time_wait; 983 goto do_time_wait;
985 } 984 }
986 985
987 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) { 986 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
988 dccp_pr_debug("xfrm4_policy_check failed\n");
989 goto discard_and_relse; 987 goto discard_and_relse;
990 }
991
992 if (sk_filter(sk, skb, 0)) {
993 dccp_pr_debug("sk_filter failed\n");
994 goto discard_and_relse;
995 }
996
997 skb->dev = NULL;
998 988
999 bh_lock_sock(sk); 989 return sk_receive_skb(sk, skb);
1000 rc = 0;
1001 if (!sock_owned_by_user(sk))
1002 rc = dccp_v4_do_rcv(sk, skb);
1003 else
1004 sk_add_backlog(sk, skb);
1005 bh_unlock_sock(sk);
1006
1007 sock_put(sk);
1008 return rc;
1009 990
1010no_dccp_socket: 991no_dccp_socket:
1011 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) 992 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 599b0be21515..2e194c8f9953 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -1032,7 +1032,6 @@ static int dccp_v6_rcv(struct sk_buff **pskb, unsigned int *nhoffp)
1032 const struct dccp_hdr *dh; 1032 const struct dccp_hdr *dh;
1033 struct sk_buff *skb = *pskb; 1033 struct sk_buff *skb = *pskb;
1034 struct sock *sk; 1034 struct sock *sk;
1035 int rc;
1036 1035
1037 /* Step 1: Check header basics: */ 1036 /* Step 1: Check header basics: */
1038 1037
@@ -1077,21 +1076,7 @@ static int dccp_v6_rcv(struct sk_buff **pskb, unsigned int *nhoffp)
1077 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) 1076 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
1078 goto discard_and_relse; 1077 goto discard_and_relse;
1079 1078
1080 if (sk_filter(sk, skb, 0)) 1079 return sk_receive_skb(sk, skb) ? -1 : 0;
1081 goto discard_and_relse;
1082
1083 skb->dev = NULL;
1084
1085 bh_lock_sock(sk);
1086 rc = 0;
1087 if (!sock_owned_by_user(sk))
1088 rc = dccp_v6_do_rcv(sk, skb);
1089 else
1090 sk_add_backlog(sk, skb);
1091 bh_unlock_sock(sk);
1092
1093 sock_put(sk);
1094 return rc ? -1 : 0;
1095 1080
1096no_dccp_socket: 1081no_dccp_socket:
1097 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) 1082 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
diff --git a/net/decnet/dn_nsp_in.c b/net/decnet/dn_nsp_in.c
index 369f25b60f3f..44bda85e678f 100644
--- a/net/decnet/dn_nsp_in.c
+++ b/net/decnet/dn_nsp_in.c
@@ -793,7 +793,6 @@ static int dn_nsp_rx_packet(struct sk_buff *skb)
793got_it: 793got_it:
794 if (sk != NULL) { 794 if (sk != NULL) {
795 struct dn_scp *scp = DN_SK(sk); 795 struct dn_scp *scp = DN_SK(sk);
796 int ret;
797 796
798 /* Reset backoff */ 797 /* Reset backoff */
799 scp->nsp_rxtshift = 0; 798 scp->nsp_rxtshift = 0;
@@ -807,21 +806,7 @@ got_it:
807 goto free_out; 806 goto free_out;
808 } 807 }
809 808
810 bh_lock_sock(sk); 809 return sk_receive_skb(sk, skb);
811 ret = NET_RX_SUCCESS;
812 if (decnet_debug_level & 8)
813 printk(KERN_DEBUG "NSP: 0x%02x 0x%02x 0x%04x 0x%04x %d\n",
814 (int)cb->rt_flags, (int)cb->nsp_flags,
815 (int)cb->src_port, (int)cb->dst_port,
816 !!sock_owned_by_user(sk));
817 if (!sock_owned_by_user(sk))
818 ret = dn_nsp_backlog_rcv(sk, skb);
819 else
820 sk_add_backlog(sk, skb);
821 bh_unlock_sock(sk);
822 sock_put(sk);
823
824 return ret;
825 } 810 }
826 811
827 return dn_nsp_no_socket(skb, reason); 812 return dn_nsp_no_socket(skb, reason);