Skip to contentSkip to conversation

Demise of AX.25 raw sockets

PATCH Steven Whitehouse 4 participants 7 messages Jul 6, 2003 – Sep 3, 2003 Networking

lore
Share & tools
lore
#0 lore raw

Hi,

As part of the work currently going on to improve the AX.25 code in 2.5 kernels I'm proposing that the support for AX.25 raw sockets should be removed. So if you disagree, please say now :-)

There are a number of reasons why I don't think that we need support for raw sockets in AX.25:

- No application that I've seen actually uses them (of course someone on this list might prove me wrong on this point!)
- They are broken and haven't worked for some time and I've not seen any bug reports posted recently (again leading me to think nothing uses them).
- The PF_PACKET family would seem to be just as good an option for application writers.
- Its unclear exactly what the rules were for which packets should be delivered to raw sockets.

So I think they are obsolete, but maybe someone knows better? If I don't hear negative responses in the next few days I'll send the attached patch to davem for inclusion in the next 2.5 kernel,

Steve.

------------------------------------------------------------------------------

include/net/ax25.h +0 -2
diff -Nru linux-2.5.74/include/net/ax25.h linux/include/net/ax25.h
@@ -211,8 +211,6 @@
 struct sock *ax25_find_listener(ax25_address *, int, struct net_device *, int);
 struct sock *ax25_get_socket(ax25_address *, ax25_address *, int);
 extern ax25_cb *ax25_find_cb(ax25_address *, ax25_address *, ax25_digi *, struct net_device *);
-extern struct sock *ax25_addr_match(ax25_address *);
-extern void ax25_send_to_raw(struct sock *, struct sk_buff *, int);
 extern void ax25_destroy_socket(ax25_cb *);
 extern ax25_cb *ax25_create_cb(void);
 extern void ax25_fillin_cb(ax25_cb *, ax25_dev *);
net/ax25/TODO +0 -3
diff -Nru linux-2.5.74/net/ax25/TODO linux/net/ax25/TODO
@@ -18,7 +18,4 @@
 
 Implement proper socket locking in netrom and rose.
 
-Check socket locking when ax25_rcv is sending to raw sockets.  In particular
-ax25_send_to_raw() seems fishy.  Heck - ax25_rcv is fishy.
-
 Handle XID and TEST frames properly.
net/ax25/af_ax25.c +0 -41

53 lines not on this page · raw message

net/ax25/ax25_in.c +1 -6
diff -Nru linux-2.5.74/net/ax25/ax25_in.c linux/net/ax25/ax25_in.c
@@ -193,7 +193,7 @@
 {
 	ax25_address src, dest, *next_digi = NULL;
 	int type = 0, mine = 0, dama;
-	struct sock *make, *sk, *raw;
+	struct sock *make, *sk;
 	ax25_digi dp, reverse_dp;
 	ax25_cb *ax25;
 	ax25_dev *ax25_dev;
@@ -240,11 +240,6 @@
 	/* UI frame - bypass LAPB processing */
 	if ((*skb->data & ~0x10) == AX25_UI && dp.lastrepeat + 1 == dp.ndigi) {
 		skb->h.raw = skb->data + 2;		/* skip control and pid */
-
-		if ((raw = ax25_addr_match(&dest)) != NULL) {
-			ax25_send_to_raw(raw, skb, skb->data[1]);
-			release_sock(raw);
-		}
 
 		if (!mine && ax25cmp(&dest, (ax25_address *)dev->broadcast) != 0) {
 			kfree_skb(skb);
#1 lore raw
Quoted 2 lines · Steven Whitehouse

- No application that I've seen actually uses them (of course someone on this list might prove me wrong on this point!)

About three years ago I rewrote netromd to use a PF_AX25, SOCK_RAW, NETROM_PID socket for receiving NODES broadcasts. The main reason for the rewrite was to support digipeated broadcasts. Raw socket was an easy way of getting the digi path.

Unfortunately at that time something was broken in the kernel (ax25_getname IIRC) so it only worked with a patched kernel. Also there wasn't much interest in it so it was all forgotten.

I don't know of any other programs using raw AX.25 sockets.

Quoted 2 lines

- They are broken and haven't worked for some time and I've not seen any bug reports posted recently (again leading me to think nothing uses them).

How exactly is it broken?

Quoted 2 lines

- The PF_PACKET family would seem to be just as good an option for application writers.

Most applications use PF_PACKET but there is the problem that it needs elevated privileges. Granted, using a raw socket and binding it to anything else than your own callsign also needs privileges so this may not be an issue.

Anyway using PF_PACKET for just about everything like it is currently is in my opinion ugly so I would prefer maintaining raw socket support if possible.

Quoted 2 lines

- Its unclear exactly what the rules were for which packets should be delivered to raw sockets.

Signature · 3 lines
Tomi Manninen           Internet:  [email protected]
OH2BNS                  AX.25:     [email protected]
KP20ME04                Amprnet:   [email protected]
#2 lore raw

Hi,

Quoted 11 lines · Steven Whitehouse
Quoted 3 lines

- No application that I've seen actually uses them (of course someone on this list might prove me wrong on this point!)

About three years ago I rewrote netromd to use a PF_AX25, SOCK_RAW, NETROM_PID socket for receiving NODES broadcasts. The main reason for the rewrite was to support digipeated broadcasts. Raw socket was an easy way of getting the digi path.

Quoted 6 lines

Unfortunately at that time something was broken in the kernel (ax25_getname IIRC) so it only worked with a patched kernel. Also there wasn't much interest in it so it was all forgotten.

I don't know of any other programs using raw AX.25 sockets.

Ok. Thats not too much of a problem it seems but another use has now also been posted on the list so I'll investigate that too.

Quoted 5 lines
Quoted 2 lines

- They are broken and haven't worked for some time and I've not seen any bug reports posted recently (again leading me to think nothing uses them).

How exactly is it broken?

If you look at the packet delivery code and ignore the fact that the locking is broken for the moment then it looks rather odd since it does:

1. Search for first socket which is of type raw and has a matching address. If found then do:
2. Deliver to all raw sockets which come after the first one and have enough buffer space left (i.e. there is no match on the address) and also match on the protocol field.

So whether or not you see a packet not destined for the address you are listening for depends on the "random" position of your socket in the AX.25 sockets list. Also note that the socket found in step 1 might not actually get the packet sent to it in the case that it matches on address but not on protocol although it will still trigger step 2. Confused? I hoped that if applications existed (which it appears they do) it might clarify whats supposed to happen :-)

Quoted 12 lines
Quoted 2 lines

- The PF_PACKET family would seem to be just as good an option for application writers.

Most applications use PF_PACKET but there is the problem that it needs elevated privileges. Granted, using a raw socket and binding it to anything else than your own callsign also needs privileges so this may not be an issue.

Anyway using PF_PACKET for just about everything like it is currently is in my opinion ugly so I would prefer maintaining raw socket support if possible.

Ok. Well it looks now like there are uses for it, so I'll fix it rather than removing it - I just didn't want to spend time on it if nobody was using it,

Steve.

#3 lore raw
In reply to Steven Whitehouse

The PACSAT PB&PG programs uses raw sockets.

        /* open up the AX25 datagram socket to send file requests */
        if ((s_file = socket(PF_AX25, SOCK_RAW, PID_FILE)) == -1)
        {
                perror("socket");
                return(1);
        }

        /* open up the AX25 datagram socket to send directory requests */
        if ((s_directory = socket(PF_AX25, SOCK_RAW, PID_DIRECTORY)) == 
-1)
        {
                perror("socket");
                return(1);
        }

-- Edson, 7n4ncl

Quoted 136 lines · Steven Whitehouse

Hi,

As part of the work currently going on to improve the AX.25 code in 2.5 kernels I'm proposing that the support for AX.25 raw sockets should be removed. So if you disagree, please say now :-)

There are a number of reasons why I don't think that we need support for raw sockets in AX.25:

- No application that I've seen actually uses them (of course someone on this list might prove me wrong on this point!)
- They are broken and haven't worked for some time and I've not seen any bug reports posted recently (again leading me to think nothing uses them).
- The PF_PACKET family would seem to be just as good an option for application writers.
- Its unclear exactly what the rules were for which packets should be delivered to raw sockets.

So I think they are obsolete, but maybe someone knows better? If I don't hear negative responses in the next few days I'll send the attached patch to davem for inclusion in the next 2.5 kernel,

Steve.

------------------------------------------------------------------------------

diff -Nru linux-2.5.74/include/net/ax25.h linux/include/net/ax25.h

include/net/ax25.h +0 -2
@@ -211,8 +211,6 @@
 struct sock *ax25_find_listener(ax25_address *, int, struct net_device *, int);
 struct sock *ax25_get_socket(ax25_address *, ax25_address *, int);
 extern ax25_cb *ax25_find_cb(ax25_address *, ax25_address *, ax25_digi *, struct net_device *);
-extern struct sock *ax25_addr_match(ax25_address *);
-extern void ax25_send_to_raw(struct sock *, struct sk_buff *, int);
 extern void ax25_destroy_socket(ax25_cb *);
 extern ax25_cb *ax25_create_cb(void);
 extern void ax25_fillin_cb(ax25_cb *, ax25_dev *);

diff -Nru linux-2.5.74/net/ax25/TODO linux/net/ax25/TODO

net/ax25/TODO +0 -3
@@ -18,7 +18,4 @@
 
 Implement proper socket locking in netrom and rose.
 
-Check socket locking when ax25_rcv is sending to raw sockets.  In particular
-ax25_send_to_raw() seems fishy.  Heck - ax25_rcv is fishy.
-
 Handle XID and TEST frames properly.

diff -Nru linux-2.5.74/net/ax25/af_ax25.c linux/net/ax25/af_ax25.c

net/ax25/af_ax25.c +0 -41
@@ -251,45 +251,6 @@
 }
 
 /*
- *	Look for any matching address - RAW sockets can bind to arbitrary names
- */
-struct sock *ax25_addr_match(ax25_address *addr)
-{
-	struct sock *sk = NULL;
-	ax25_cb *s;
-
-	spin_lock_bh(&ax25_list_lock);
-	for (s = ax25_list; s != NULL; s = s->next) {
-		if (s->sk != NULL && ax25cmp(&s->source_addr, addr) == 0 &&
-		    s->sk->sk_type == SOCK_RAW) {
-			sk = s->sk;
-			lock_sock(sk);
-			break;
-		}
-	}
-	spin_unlock_bh(&ax25_list_lock);
-
-	return sk;
-}
-
-void ax25_send_to_raw(struct sock *sk, struct sk_buff *skb, int proto)
-{
-	struct sk_buff *copy;
-	struct hlist_node *node;
-
-	sk_for_each_from(sk, node)
-		if (sk->sk_type == SOCK_RAW &&
-		    sk->sk_protocol == proto &&
-		    atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf) {
-			if ((copy = skb_clone(skb, GFP_ATOMIC)) == NULL)
-				return;
-
-			if (sock_queue_rcv_skb(sk, copy) != 0)
-				kfree_skb(copy);
-		}
-}
-
-/*
  *	Deferred destroy.
  */
 void ax25_destroy_socket(ax25_cb *);
@@ -830,8 +791,6 @@
 		}
 		break;
 
-	case SOCK_RAW:
-		break;
 	default:
 		return -ESOCKTNOSUPPORT;
 	}

diff -Nru linux-2.5.74/net/ax25/ax25_in.c linux/net/ax25/ax25_in.c

net/ax25/ax25_in.c +1 -7
@@ -193,7 +193,7 @@
 {
 	ax25_address src, dest, *next_digi = NULL;
 	int type = 0, mine = 0, dama;
-	struct sock *make, *sk, *raw;
+	struct sock *make, *sk;
 	ax25_digi dp, reverse_dp;
 	ax25_cb *ax25;
 	ax25_dev *ax25_dev;
@@ -240,11 +240,6 @@
 	/* UI frame - bypass LAPB processing */
 	if ((*skb->data & ~0x10) == AX25_UI && dp.lastrepeat + 1 == dp.ndigi) {
 		skb->h.raw = skb->data + 2;		/* skip control and pid */
-
-		if ((raw = ax25_addr_match(&dest)) != NULL) {
-			ax25_send_to_raw(raw, skb, skb->data[1]);
-			release_sock(raw);
-		}
 
 		if (!mine && ax25cmp(&dest, (ax25_address *)dev->broadcast) != 0) {
 			kfree_skb(skb);
-

To unsubscribe from this list: send the line "unsubscribe linux-hams" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Hi,

To save me searching the archives can you point to a URL of the code? I'd like to see exactly what this code expects raw sockets to do,

Steve.

Quoted 165 lines

The PACSAT PB&PG programs uses raw sockets.

        /* open up the AX25 datagram socket to send file requests */
        if ((s_file = socket(PF_AX25, SOCK_RAW, PID_FILE)) == -1)
        {
                perror("socket");
                return(1);
        }

        /* open up the AX25 datagram socket to send directory requests */
        if ((s_directory = socket(PF_AX25, SOCK_RAW, PID_DIRECTORY)) == 
-1)
        {
                perror("socket");
                return(1);
        }

-- Edson, 7n4ncl

Quoted 132 lines · Steven Whitehouse

Hi,

As part of the work currently going on to improve the AX.25 code in 2.5 kernels I'm proposing that the support for AX.25 raw sockets should be removed. So if you disagree, please say now :-)

There are a number of reasons why I don't think that we need support for raw sockets in AX.25:

- No application that I've seen actually uses them (of course someone on this list might prove me wrong on this point!)
- They are broken and haven't worked for some time and I've not seen any bug reports posted recently (again leading me to think nothing uses them).
- The PF_PACKET family would seem to be just as good an option for application writers.
- Its unclear exactly what the rules were for which packets should be delivered to raw sockets.

So I think they are obsolete, but maybe someone knows better? If I don't hear negative responses in the next few days I'll send the attached patch to davem for inclusion in the next 2.5 kernel,

Steve.

------------------------------------------------------------------------------

diff -Nru linux-2.5.74/include/net/ax25.h linux/include/net/ax25.h

include/net/ax25.h +0 -2
@@ -211,8 +211,6 @@
 struct sock *ax25_find_listener(ax25_address *, int, struct net_device *, int);
 struct sock *ax25_get_socket(ax25_address *, ax25_address *, int);
 extern ax25_cb *ax25_find_cb(ax25_address *, ax25_address *, ax25_digi *, struct net_device *);
-extern struct sock *ax25_addr_match(ax25_address *);
-extern void ax25_send_to_raw(struct sock *, struct sk_buff *, int);
 extern void ax25_destroy_socket(ax25_cb *);
 extern ax25_cb *ax25_create_cb(void);
 extern void ax25_fillin_cb(ax25_cb *, ax25_dev *);

diff -Nru linux-2.5.74/net/ax25/TODO linux/net/ax25/TODO

net/ax25/TODO +0 -3
@@ -18,7 +18,4 @@
 
 Implement proper socket locking in netrom and rose.
 
-Check socket locking when ax25_rcv is sending to raw sockets.  In particular
-ax25_send_to_raw() seems fishy.  Heck - ax25_rcv is fishy.
-
 Handle XID and TEST frames properly.

diff -Nru linux-2.5.74/net/ax25/af_ax25.c linux/net/ax25/af_ax25.c

net/ax25/af_ax25.c +0 -41
@@ -251,45 +251,6 @@
 }
 
 /*
- *	Look for any matching address - RAW sockets can bind to arbitrary names
- */
-struct sock *ax25_addr_match(ax25_address *addr)
-{
-	struct sock *sk = NULL;
-	ax25_cb *s;
-
-	spin_lock_bh(&ax25_list_lock);
-	for (s = ax25_list; s != NULL; s = s->next) {
-		if (s->sk != NULL && ax25cmp(&s->source_addr, addr) == 0 &&
-		    s->sk->sk_type == SOCK_RAW) {
-			sk = s->sk;
-			lock_sock(sk);
-			break;
-		}
-	}
-	spin_unlock_bh(&ax25_list_lock);
-
-	return sk;
-}
-
-void ax25_send_to_raw(struct sock *sk, struct sk_buff *skb, int proto)
-{
-	struct sk_buff *copy;
-	struct hlist_node *node;
-
-	sk_for_each_from(sk, node)
-		if (sk->sk_type == SOCK_RAW &&
-		    sk->sk_protocol == proto &&
-		    atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf) {
-			if ((copy = skb_clone(skb, GFP_ATOMIC)) == NULL)
-				return;
-
-			if (sock_queue_rcv_skb(sk, copy) != 0)
-				kfree_skb(copy);
-		}
-}
-
-/*
  *	Deferred destroy.
  */
 void ax25_destroy_socket(ax25_cb *);
@@ -830,8 +791,6 @@
 		}
 		break;
 
-	case SOCK_RAW:
-		break;
 	default:
 		return -ESOCKTNOSUPPORT;
 	}

diff -Nru linux-2.5.74/net/ax25/ax25_in.c linux/net/ax25/ax25_in.c

net/ax25/ax25_in.c +1 -7
@@ -193,7 +193,7 @@
 {
 	ax25_address src, dest, *next_digi = NULL;
 	int type = 0, mine = 0, dama;
-	struct sock *make, *sk, *raw;
+	struct sock *make, *sk;
 	ax25_digi dp, reverse_dp;
 	ax25_cb *ax25;
 	ax25_dev *ax25_dev;
@@ -240,11 +240,6 @@
 	/* UI frame - bypass LAPB processing */
 	if ((*skb->data & ~0x10) == AX25_UI && dp.lastrepeat + 1 == dp.ndigi) {
 		skb->h.raw = skb->data + 2;		/* skip control and pid */
-
-		if ((raw = ax25_addr_match(&dest)) != NULL) {
-			ax25_send_to_raw(raw, skb, skb->data[1]);
-			release_sock(raw);
-		}
 
 		if (!mine && ax25cmp(&dest, (ax25_address *)dev->broadcast) != 0) {
 			kfree_skb(skb);
-
Quoted 4 lines

To unsubscribe from this list: send the line "unsubscribe linux-hams" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

-
To unsubscribe from this list: send the line "unsubscribe linux-hams" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

Hi Steve,

I havn't checked this account for some time, hence the late response. You can find PB and PG for Linux at this URL: ftp://metalab.unc.edu/pub/linux/apps/ham/pbpg-2.1.tar.gz or at this URL: ftp://ftp.amsat.org/amsat/software/Linux/pbpg-2.1.tar.gz

Best 73 de Bent/OZ6BL
Maintainer of PB and PG for Linux

#6 lore raw

Hi,

Thats ok. Nothing has happened yet anyway as I've got rather busy with work all of a sudden. I'll look at the problem again in a couple of months or so if nobody else has solved it first along with the other items on my AX.25 todo list.

I have recently got some new radio kit too, so it will be much easier for me to test things once I've moved. Sorry for the delay,

Steve.

Quoted 13 lines

Hi Steve,

I havn't checked this account for some time, hence the late response. You can find PB and PG for Linux at this URL:
ftp://metalab.unc.edu/pub/linux/apps/ham/pbpg-2.1.tar.gz or at this URL:
ftp://ftp.amsat.org/amsat/software/Linux/pbpg-2.1.tar.gz

Best 73 de Bent/OZ6BL
Maintainer of PB and PG for Linux