Skip to contentSkip to conversation

Get rid of sk_protinfo use in rose

PATCH In review Ralf Baechle DL5RB 2 participants 3 messages Mar 21, 2005 – Mar 23, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Get rid of sk_protinfo use in rose

Below patch puts struct sock into rose_cb to get rid of the need for the use of sk_protinfo in rose_sk(). While we're touching the data structure convert it from a typedef into a struct.

net/rose/rose_in.c +5 -5
Index: bk-afu/net/rose/rose_in.c
===================================================================
@@ -41,7 +41,7 @@
  */
 static int rose_state1_machine(struct sock *sk, struct sk_buff *skb, int frametype)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 
 	switch (frametype) {
 	case ROSE_CALL_ACCEPTED:
@@ -78,7 +78,7 @@
  */
 static int rose_state2_machine(struct sock *sk, struct sk_buff *skb, int frametype)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 
 	switch (frametype) {
 	case ROSE_CLEAR_REQUEST:
@@ -106,7 +106,7 @@
  */
 static int rose_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype, int ns, int nr, int q, int d, int m)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 	int queued = 0;
 
 	switch (frametype) {
@@ -216,7 +216,7 @@
  */
 static int rose_state4_machine(struct sock *sk, struct sk_buff *skb, int frametype)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 
 	switch (frametype) {
 	case ROSE_RESET_REQUEST:
@@ -265,7 +265,7 @@
 /* Higher level upcall for a LAPB frame */
 int rose_process_rx_frame(struct sock *sk, struct sk_buff *skb)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 	int queued = 0, frametype, ns, nr, q, d, m;
 
 	if (rose->state == ROSE_STATE_0)
net/rose/rose_route.c +2 -1
Index: bk-afu/net/rose/rose_route.c
===================================================================
@@ -899,7 +899,8 @@
 	 */
 	if ((sk = rose_find_socket(lci, rose_neigh)) != NULL) {
 		if (frametype == ROSE_CALL_REQUEST) {
-			rose_cb *rose = rose_sk(sk);
+			struct rose_sock *rose = rose_sk(sk);
+
 			/* Remove an existing unused socket */
 			rose_clear_queues(sk);
 			rose->cause	 = ROSE_NETWORK_CONGESTION;
net/rose/rose_timer.c +7 -7
Index: bk-afu/net/rose/rose_timer.c
===================================================================
@@ -46,7 +46,7 @@
 
 void rose_start_t1timer(struct sock *sk)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 
 	del_timer(&rose->timer);
 
@@ -59,7 +59,7 @@
 
 void rose_start_t2timer(struct sock *sk)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 
 	del_timer(&rose->timer);
 
@@ -72,7 +72,7 @@
 
 void rose_start_t3timer(struct sock *sk)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 
 	del_timer(&rose->timer);
 
@@ -85,7 +85,7 @@
 
 void rose_start_hbtimer(struct sock *sk)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 
 	del_timer(&rose->timer);
 
@@ -98,7 +98,7 @@
 
 void rose_start_idletimer(struct sock *sk)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 
 	del_timer(&rose->idletimer);
 
@@ -129,7 +129,7 @@
 static void rose_heartbeat_expiry(unsigned long param)
 {
 	struct sock *sk = (struct sock *)param;
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 
 	bh_lock_sock(sk);
 	switch (rose->state) {
@@ -166,7 +166,7 @@
 static void rose_timer_expiry(unsigned long param)
 {
 	struct sock *sk = (struct sock *)param;
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 
 	bh_lock_sock(sk);
 	switch (rose->state) {
include/net/rose.h +6 -4
Index: bk-afu/include/net/rose.h
===================================================================
@@ -6,7 +6,9 @@
 
 #ifndef _ROSE_H
 #define _ROSE_H 
+
 #include <linux/rose.h>
+#include <net/sock.h>
 
 #define	ROSE_ADDR_LEN			5
 
@@ -114,7 +116,8 @@
 	unsigned int		rand;
 };
 
-typedef struct {
+struct rose_sock {
+	struct sock		sock;
 	rose_address		source_addr,   dest_addr;
 	ax25_address		source_call,   dest_call;
 	unsigned char		source_ndigis, dest_ndigis;
@@ -135,10 +138,9 @@
 	struct rose_facilities_struct facilities;
 	struct timer_list	timer;
 	struct timer_list	idletimer;
-	struct sock		*sk;		/* Backlink to socket */
-} rose_cb;
+};
 
-#define rose_sk(__sk) ((rose_cb *)(__sk)->sk_protinfo)
+#define rose_sk(sk) ((struct rose_sock *)(sk))
 
 /* af_rose.c */
 extern ax25_address rose_callsign;
net/rose/rose_subr.c +6 -6
Index: bk-afu/net/rose/rose_subr.c
===================================================================
@@ -28,7 +28,7 @@
 #include <linux/interrupt.h>
 #include <net/rose.h>
 
-static int rose_create_facilities(unsigned char *buffer, rose_cb *rose);
+static int rose_create_facilities(unsigned char *buffer, struct rose_sock *rose);
 
 /*
  *	This routine purges all of the queues of frames.
@@ -47,7 +47,7 @@
 void rose_frames_acked(struct sock *sk, unsigned short nr)
 {
 	struct sk_buff *skb;
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 
 	/*
 	 * Remove all the ack-ed frames from the ack queue.
@@ -85,7 +85,7 @@
  */
 int rose_validate_nr(struct sock *sk, unsigned short nr)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 	unsigned short vc = rose->va;
 
 	while (vc != rose->vs) {
@@ -102,7 +102,7 @@
  */
 void rose_write_internal(struct sock *sk, int frametype)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 	struct sk_buff *skb;
 	unsigned char  *dptr;
 	unsigned char  lci1, lci2;
@@ -396,7 +396,7 @@
 	return 1;
 }
 
-static int rose_create_facilities(unsigned char *buffer, rose_cb *rose)
+static int rose_create_facilities(unsigned char *buffer, struct rose_sock *rose)
 {
 	unsigned char *p = buffer + 1;
 	char *callsign;
@@ -492,7 +492,7 @@
 
 void rose_disconnect(struct sock *sk, int reason, int cause, int diagnostic)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 
 	rose_stop_timer(sk);
 	rose_stop_idletimer(sk);
net/rose/rose_out.c +3 -3
Index: bk-afu/net/rose/rose_out.c
===================================================================
@@ -33,7 +33,7 @@
  */
 static void rose_send_iframe(struct sock *sk, struct sk_buff *skb)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 
 	if (skb == NULL)
 		return;
@@ -48,7 +48,7 @@
 
 void rose_kick(struct sock *sk)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 	struct sk_buff *skb, *skbn;
 	unsigned short start, end;
 
@@ -112,7 +112,7 @@
 
 void rose_enquiry_response(struct sock *sk)
 {
-	rose_cb *rose = rose_sk(sk);
+	struct rose_sock *rose = rose_sk(sk);
 
 	if (rose->condition & ROSE_COND_OWN_RX_BUSY)
 		rose_write_internal(sk, ROSE_RNR);
net/rose/af_rose.c +20 -37

177 lines not on this page · raw message

#1 lore raw
Quoted 3 lines · On Mon, Mar 21, 2005 at 09:50:37AM +0000, Ralf Baechle DL5RB wrote:

Below patch puts struct sock into rose_cb to get rid of the need for the use of sk_protinfo in rose_sk(). While we're touching the data structure convert it from a typedef into a struct.

The previous two patches leave the same thing to do in ax25 also - where it's a more complicated thing to do since currently an ax25_cb may exist without a struct sock - which unfortunately messes up locking.

Ralf

maintainer
#2 lore raw
In reply to Ralf Baechle DL5RB
Quoted 3 lines · On Mon, 21 Mar 2005 09:50:37 +0000 Ralf Baechle DL5RB <[email protected]>…

Below patch puts struct sock into rose_cb to get rid of the need for the use of sk_protinfo in rose_sk(). While we're touching the data structure convert it from a typedef into a struct.

Also applied, thanks Ralf.