aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@mandriva.com>2005-09-22 03:40:59 -0400
committerArnaldo Carvalho de Melo <acme@mandriva.com>2005-09-22 03:40:59 -0400
commit04e4223f44b89e50f275cb6b95a58ebe2c4909be (patch)
tree16f797eef4e2620b4150ddb94da78eaeb2baa679
parentafdbe35787ea3390af0f1dd38b3dd9d8a8d313e7 (diff)
[LLC]: Do better struct sock accounting on skbs
Signed-off-by: Jochen Friedrich <jochen@scram.de> Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
-rw-r--r--include/net/llc_sap.h6
-rw-r--r--net/llc/af_llc.c2
-rw-r--r--net/llc/llc_c_ac.c2
-rw-r--r--net/llc/llc_conn.c14
-rw-r--r--net/llc/llc_sap.c8
5 files changed, 18 insertions, 14 deletions
diff --git a/include/net/llc_sap.h b/include/net/llc_sap.h
index 6dd4cdccca42..9dcfcf4a4abb 100644
--- a/include/net/llc_sap.h
+++ b/include/net/llc_sap.h
@@ -12,11 +12,13 @@
12 * See the GNU General Public License for more details. 12 * See the GNU General Public License for more details.
13 */ 13 */
14struct llc_sap; 14struct llc_sap;
15struct sk_buff;
16struct net_device; 15struct net_device;
16struct sk_buff;
17struct sock;
17 18
18extern void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb); 19extern void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb);
19extern void llc_save_primitive(struct sk_buff* skb, unsigned char prim); 20extern void llc_save_primitive(struct sock *sk, struct sk_buff* skb,
21 unsigned char prim);
20extern struct sk_buff *llc_alloc_frame(struct net_device *dev); 22extern struct sk_buff *llc_alloc_frame(struct net_device *dev);
21 23
22extern void llc_build_and_send_test_pkt(struct llc_sap *sap, 24extern void llc_build_and_send_test_pkt(struct llc_sap *sap,
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index f536369cdb52..ad9aad807aa8 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -628,7 +628,6 @@ static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags)
628 /* put original socket back into a clean listen state. */ 628 /* put original socket back into a clean listen state. */
629 sk->sk_state = TCP_LISTEN; 629 sk->sk_state = TCP_LISTEN;
630 sk->sk_ack_backlog--; 630 sk->sk_ack_backlog--;
631 skb->sk = NULL;
632 dprintk("%s: ok success on %02X, client on %02X\n", __FUNCTION__, 631 dprintk("%s: ok success on %02X, client on %02X\n", __FUNCTION__,
633 llc_sk(sk)->addr.sllc_sap, newllc->daddr.lsap); 632 llc_sk(sk)->addr.sllc_sap, newllc->daddr.lsap);
634frees: 633frees:
@@ -740,7 +739,6 @@ static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock,
740 lock_sock(sk); 739 lock_sock(sk);
741 if (!skb) 740 if (!skb)
742 goto release; 741 goto release;
743 skb->sk = sk;
744 skb->dev = llc->dev; 742 skb->dev = llc->dev;
745 skb->protocol = llc_proto_type(addr->sllc_arphrd); 743 skb->protocol = llc_proto_type(addr->sllc_arphrd);
746 skb_reserve(skb, hdrlen); 744 skb_reserve(skb, hdrlen);
diff --git a/net/llc/llc_c_ac.c b/net/llc/llc_c_ac.c
index 9d9b6c8aeb44..c1e75103189a 100644
--- a/net/llc/llc_c_ac.c
+++ b/net/llc/llc_c_ac.c
@@ -1335,7 +1335,7 @@ static void llc_conn_tmr_common_cb(unsigned long timeout_data, u8 type)
1335 if (skb) { 1335 if (skb) {
1336 struct llc_conn_state_ev *ev = llc_conn_ev(skb); 1336 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
1337 1337
1338 skb->sk = sk; 1338 skb_set_owner_r(skb, sk);
1339 ev->type = type; 1339 ev->type = type;
1340 llc_process_tmr_ev(sk, skb); 1340 llc_process_tmr_ev(sk, skb);
1341 } 1341 }
diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c
index d3783f8ee481..9f0e10e0978d 100644
--- a/net/llc/llc_conn.c
+++ b/net/llc/llc_conn.c
@@ -90,8 +90,8 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
90 90
91 switch (ev->ind_prim) { 91 switch (ev->ind_prim) {
92 case LLC_DATA_PRIM: 92 case LLC_DATA_PRIM:
93 llc_save_primitive(skb, LLC_DATA_PRIM); 93 llc_save_primitive(sk, skb, LLC_DATA_PRIM);
94 if (sock_queue_rcv_skb(sk, skb)) { 94 if (unlikely(sock_queue_rcv_skb(sk, skb))) {
95 /* 95 /*
96 * shouldn't happen 96 * shouldn't happen
97 */ 97 */
@@ -103,6 +103,11 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
103 case LLC_CONN_PRIM: { 103 case LLC_CONN_PRIM: {
104 struct sock *parent = skb->sk; 104 struct sock *parent = skb->sk;
105 105
106 skb_orphan(skb);
107 /*
108 * Set the skb->sk to the new struct sock, so that at accept
109 * type the upper layer can get the newly created struct sock.
110 */
106 skb->sk = sk; 111 skb->sk = sk;
107 skb_queue_tail(&parent->sk_receive_queue, skb); 112 skb_queue_tail(&parent->sk_receive_queue, skb);
108 sk->sk_state_change(parent); 113 sk->sk_state_change(parent);
@@ -702,10 +707,9 @@ void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb)
702 memcpy(&llc->daddr, &saddr, sizeof(llc->daddr)); 707 memcpy(&llc->daddr, &saddr, sizeof(llc->daddr));
703 llc_sap_add_socket(sap, sk); 708 llc_sap_add_socket(sap, sk);
704 sock_hold(sk); 709 sock_hold(sk);
710 skb_set_owner_r(skb, parent);
705 sock_put(parent); 711 sock_put(parent);
706 skb->sk = parent; 712 }
707 } else
708 skb->sk = sk;
709 bh_lock_sock(sk); 713 bh_lock_sock(sk);
710 if (!sock_owned_by_user(sk)) 714 if (!sock_owned_by_user(sk))
711 llc_conn_rcv(sk, skb); 715 llc_conn_rcv(sk, skb);
diff --git a/net/llc/llc_sap.c b/net/llc/llc_sap.c
index 0adaa289bf0a..9f064b3a4335 100644
--- a/net/llc/llc_sap.c
+++ b/net/llc/llc_sap.c
@@ -45,12 +45,12 @@ struct sk_buff *llc_alloc_frame(struct net_device *dev)
45 return skb; 45 return skb;
46} 46}
47 47
48void llc_save_primitive(struct sk_buff* skb, u8 prim) 48void llc_save_primitive(struct sock *sk, struct sk_buff* skb, u8 prim)
49{ 49{
50 struct sockaddr_llc *addr = llc_ui_skb_cb(skb); 50 struct sockaddr_llc *addr = llc_ui_skb_cb(skb);
51 51
52 /* save primitive for use by the user. */ 52 /* save primitive for use by the user. */
53 addr->sllc_family = skb->sk->sk_family; 53 addr->sllc_family = sk->sk_family;
54 addr->sllc_arphrd = skb->dev->type; 54 addr->sllc_arphrd = skb->dev->type;
55 addr->sllc_test = prim == LLC_TEST_PRIM; 55 addr->sllc_test = prim == LLC_TEST_PRIM;
56 addr->sllc_xid = prim == LLC_XID_PRIM; 56 addr->sllc_xid = prim == LLC_XID_PRIM;
@@ -190,7 +190,7 @@ static void llc_sap_state_process(struct llc_sap *sap, struct sk_buff *skb)
190 if (skb->sk->sk_state == TCP_LISTEN) 190 if (skb->sk->sk_state == TCP_LISTEN)
191 kfree_skb(skb); 191 kfree_skb(skb);
192 else { 192 else {
193 llc_save_primitive(skb, ev->prim); 193 llc_save_primitive(skb->sk, skb, ev->prim);
194 194
195 /* queue skb to the user. */ 195 /* queue skb to the user. */
196 if (sock_queue_rcv_skb(skb->sk, skb)) 196 if (sock_queue_rcv_skb(skb->sk, skb))
@@ -309,7 +309,7 @@ void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb)
309 309
310 sk = llc_lookup_dgram(sap, &laddr); 310 sk = llc_lookup_dgram(sap, &laddr);
311 if (sk) { 311 if (sk) {
312 skb->sk = sk; 312 skb_set_owner_r(skb, sk);
313 llc_sap_rcv(sap, skb); 313 llc_sap_rcv(sap, skb);
314 sock_put(sk); 314 sock_put(sk);
315 } else 315 } else