Skip to contentSkip to conversation

wan/hdlc_x25: make lapb params configurable

PATCH Superseded Martin Schiller 3 participants 10 messages Jan 13, 2020 – Mar 26, 2020

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Martin Schiller

author maintainer
#0 lore raw

PATCH 1/2 wan/hdlc_x25: make lapb params configurable

This enables you to configure mode (DTE/DCE), Modulo, Window, T1, T2, N2 via sethdlc (which needs to be patched as well).

---
 drivers/net/wan/hdlc_x25.c      | 67 ++++++++++++++++++++++++++++++++-
 include/uapi/linux/hdlc/ioctl.h | 11 +++++-
 include/uapi/linux/if.h         |  1 +
 3 files changed, 76 insertions(+), 3 deletions(-)
drivers/net/wan/hdlc_x25.c +65 -2
index 5643675ff724..b28051eba736 100644
@@ -21,8 +21,17 @@
 #include <linux/skbuff.h>
 #include <net/x25device.h>
 
+struct x25_state {
+	x25_hdlc_proto settings;
+};
+
 static int x25_ioctl(struct net_device *dev, struct ifreq *ifr);
 
+static inline struct x25_state* state(hdlc_device *hdlc)
+{
+	return (struct x25_state *)hdlc->state;
+}
+
 /* These functions are callbacks called by LAPB layer */
 
 static void x25_connect_disconnect(struct net_device *dev, int reason, int code)
@@ -132,6 +141,8 @@ static netdev_tx_t x25_xmit(struct sk_buff *skb, struct net_device *dev)
 static int x25_open(struct net_device *dev)
 {
 	int result;
+	hdlc_device *hdlc = dev_to_hdlc(dev);
+	struct lapb_parms_struct params;
 	static const struct lapb_register_struct cb = {
 		.connect_confirmation = x25_connected,
 		.connect_indication = x25_connected,
@@ -144,6 +155,26 @@ static int x25_open(struct net_device *dev)
 	result = lapb_register(dev, &cb);
 	if (result != LAPB_OK)
 		return result;
+
+	result = lapb_getparms(dev, &params);
+	if (result != LAPB_OK)
+		return result;
+
+	if (state(hdlc)->settings.dce)
+		params.mode = params.mode | LAPB_DCE;
+
+	if (state(hdlc)->settings.modulo == 128)
+		params.mode = params.mode | LAPB_EXTENDED;
+
+	params.window = state(hdlc)->settings.window;
+	params.t1 = state(hdlc)->settings.t1;
+	params.t2 = state(hdlc)->settings.t2;
+	params.n2 = state(hdlc)->settings.n2;
+
+	result = lapb_setparms(dev, &params);
+	if (result != LAPB_OK)
+		return result;
+
 	return 0;
 }
 
@@ -186,6 +217,9 @@ static struct hdlc_proto proto = {
 
 static int x25_ioctl(struct net_device *dev, struct ifreq *ifr)
 {
+	x25_hdlc_proto __user *x25_s = ifr->ifr_settings.ifs_ifsu.x25;
+	const size_t size = sizeof(x25_hdlc_proto);
+	x25_hdlc_proto new_settings;
 	hdlc_device *hdlc = dev_to_hdlc(dev);
 	int result;
 
@@ -194,7 +228,13 @@ static int x25_ioctl(struct net_device *dev, struct ifreq *ifr)
 		if (dev_to_hdlc(dev)->proto != &proto)
 			return -EINVAL;
 		ifr->ifr_settings.type = IF_PROTO_X25;
-		return 0; /* return protocol only, no settable parameters */
+		if (ifr->ifr_settings.size < size) {
+			ifr->ifr_settings.size = size; /* data size wanted */
+			return -ENOBUFS;
+		}
+		if (copy_to_user(x25_s, &state(hdlc)->settings, size))
+			return -EFAULT;
+		return 0;
 
 	case IF_PROTO_X25:
 		if (!capable(CAP_NET_ADMIN))
@@ -203,12 +243,35 @@ static int x25_ioctl(struct net_device *dev, struct ifreq *ifr)
 		if (dev->flags & IFF_UP)
 			return -EBUSY;
 
+		if (copy_from_user(&new_settings, x25_s, size))
+			return -EFAULT;
+
+		if ((new_settings.dce != 0 &&
+		     new_settings.dce != 1) ||
+		    (new_settings.modulo != 8 &&
+		     new_settings.modulo != 128) ||
+		    new_settings.window < 1 ||
+		    (new_settings.modulo == 8 &&
+		     new_settings.window > 7) ||
+		    (new_settings.modulo == 128 &&
+		     new_settings.window > 127) ||
+		    new_settings.t1 < 1 ||
+		    new_settings.t1 > 255 ||
+		    new_settings.t2 < 1 ||
+		    new_settings.t2 > 255 ||
+		    new_settings.n2 < 1 ||
+		    new_settings.n2 > 255)
+			return -EINVAL;
+
 		result=hdlc->attach(dev, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT);
 		if (result)
 			return result;
 
-		if ((result = attach_hdlc_protocol(dev, &proto, 0)))
+		if ((result = attach_hdlc_protocol(dev, &proto,
+						   sizeof(struct x25_state))))
 			return result;
+
+		memcpy(&state(hdlc)->settings, &new_settings, size);
 		dev->type = ARPHRD_X25;
 		call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev);
 		netif_dormant_off(dev);
include/uapi/linux/hdlc/ioctl.h +10 -1
index 0fe4238e8246..3656ce8b8af0 100644
@@ -3,7 +3,7 @@
 #define __HDLC_IOCTL_H__
 
 
-#define GENERIC_HDLC_VERSION 4	/* For synchronization with sethdlc utility */
+#define GENERIC_HDLC_VERSION 5	/* For synchronization with sethdlc utility */
 
 #define CLOCK_DEFAULT   0	/* Default setting */
 #define CLOCK_EXT	1	/* External TX and RX clock - DTE */
@@ -79,6 +79,15 @@ typedef struct {
     unsigned int timeout;
 } cisco_proto;
 
+typedef struct {
+	unsigned short dce; /* 1 for DCE (network side) operation */
+	unsigned int modulo; /* modulo (8 = basic / 128 = extended) */
+	unsigned int window; /* frame window size */
+	unsigned int t1; /* timeout t1 */
+	unsigned int t2; /* timeout t2 */
+	unsigned int n2; /* frame retry counter */
+} x25_hdlc_proto;
+
 /* PPP doesn't need any info now - supply length = 0 to ioctl */
 
 #endif /* __ASSEMBLY__ */
include/uapi/linux/if.h +1 -0
index 4bf33344aab1..be714cd8c826 100644
@@ -213,6 +213,7 @@ struct if_settings {
 		fr_proto		__user *fr;
 		fr_proto_pvc		__user *fr_pvc;
 		fr_proto_pvc_info	__user *fr_pvc_info;
+		x25_hdlc_proto		__user *x25;
 
 		/* interface settings */
 		sync_serial_settings	__user *sync;
Signature · 1 line
2.20.1
author maintainer
#1 lore raw

PATCH 2/2 wan/hdlc_x25: fix skb handling

o call skb_reset_network_header() before hdlc->xmit()
o change skb proto to HDLC (0x0019) before hdlc->xmit()
o call dev_queue_xmit_nit() before hdlc->xmit()

This changes make it possible to trace (tcpdump) outgoing layer2 (ETH_P_HDLC) packets

o use a copy of the skb for lapb_data_request() in x25_xmit()

This fixes the problem, that tracing layer3 (ETH_P_X25) packets results in a malformed first byte of the packets.

---
 drivers/net/wan/hdlc_x25.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/wan/hdlc_x25.c +11 -4
index b28051eba736..434e5263eddf 100644
@@ -72,6 +72,7 @@ static int x25_data_indication(struct net_device *dev, struct sk_buff *skb)
 	unsigned char *ptr;
 
 	skb_push(skb, 1);
+	skb_reset_network_header(skb);
 
 	if (skb_cow(skb, 1))
 		return NET_RX_DROP;
@@ -88,6 +89,9 @@ static int x25_data_indication(struct net_device *dev, struct sk_buff *skb)
 static void x25_data_transmit(struct net_device *dev, struct sk_buff *skb)
 {
 	hdlc_device *hdlc = dev_to_hdlc(dev);
+	skb_reset_network_header(skb);
+	skb->protocol = hdlc_type_trans(skb, dev);
+	dev_queue_xmit_nit(skb, dev);
 	hdlc->xmit(skb, dev); /* Ignore return value :-( */
 }
 
@@ -95,16 +99,19 @@ static void x25_data_transmit(struct net_device *dev, struct sk_buff *skb)
 
 static netdev_tx_t x25_xmit(struct sk_buff *skb, struct net_device *dev)
 {
+	struct sk_buff *skbn;
 	int result;
 
 
 	/* X.25 to LAPB */
 	switch (skb->data[0]) {
 	case X25_IFACE_DATA:	/* Data to be transmitted */
-		skb_pull(skb, 1);
-		if ((result = lapb_data_request(dev, skb)) != LAPB_OK)
-			dev_kfree_skb(skb);
-		return NETDEV_TX_OK;
+		skbn = skb_copy(skb, GFP_ATOMIC);
+		skb_pull(skbn, 1);
+		skb_reset_network_header(skbn);
+		if ((result = lapb_data_request(dev, skbn)) != LAPB_OK)
+			dev_kfree_skb(skbn);
+		break;
 
 	case X25_IFACE_CONNECT:
 		if ((result = lapb_connect_request(dev))!= LAPB_OK) {
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH 2/2] wan/hdlc_x25: fix skb handling

Quoted 8 lines · Martin Schiller

o call skb_reset_network_header() before hdlc->xmit()
o change skb proto to HDLC (0x0019) before hdlc->xmit()
o call dev_queue_xmit_nit() before hdlc->xmit()

This changes make it possible to trace (tcpdump) outgoing layer2 (ETH_P_HDLC) packets

o use a copy of the skb for lapb_data_request() in x25_xmit()

It's not clear to me why

Quoted 13 lines

This fixes the problem, that tracing layer3 (ETH_P_X25) packets results in a malformed first byte of the packets.

---
 drivers/net/wan/hdlc_x25.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/wan/hdlc_x25.c +0 -0
index b28051eba736..434e5263eddf 100644

drivers/net/wan/hdlc_x25.c static int x25_data_indication(struct net_device *dev, struct sk_buff *skb) · line 77

Quoted 6 lines
drivers/net/wan/hdlc_x25.c +1 -0
@@ -72,6 +72,7 @@ static int x25_data_indication(struct net_device *dev, struct sk_buff *skb)
 	unsigned char *ptr;
 
 	skb_push(skb, 1);
+	skb_reset_network_header(skb);
 
 	if (skb_cow(skb, 1))

This skb_cow() here is for the next handler down to have a 1 byte of headroom guaranteed? It'd seem more natural to have skb_cow before the push.. not that it's related to your patch.

drivers/net/wan/hdlc_x25.c static int x25_data_indication(struct net_device *dev, struct sk_buff *skb) · line 91

Quoted 5 lines
drivers/net/wan/hdlc_x25.c +0 -0
 		return NET_RX_DROP;
@@ -88,6 +89,9 @@ static int x25_data_indication(struct net_device *dev, struct sk_buff *skb)
 static void x25_data_transmit(struct net_device *dev, struct sk_buff *skb)
 {
 	hdlc_device *hdlc = dev_to_hdlc(dev);

Please insert a new line after the variable declaration since you're touching this one.

Quoted 6 lines
drivers/net/wan/hdlc_x25.c +3 -0
+	skb_reset_network_header(skb);
+	skb->protocol = hdlc_type_trans(skb, dev);
+	dev_queue_xmit_nit(skb, dev);
 	hdlc->xmit(skb, dev); /* Ignore return value :-( */
 }
 
#4 lore raw
In reply to Martin Schiller
Quoted 10 lines · Martin Schiller

This enables you to configure mode (DTE/DCE), Modulo, Window, T1, T2, N2 via sethdlc (which needs to be patched as well).

drivers/net/wan/hdlc_x25.c +0 -0
index 5643675ff724..b28051eba736 100644

drivers/net/wan/hdlc_x25.c line 30

Quoted 10 lines
drivers/net/wan/hdlc_x25.c +5 -0
@@ -21,8 +21,17 @@
 #include <linux/skbuff.h>
 #include <net/x25device.h>
 
+struct x25_state {
+	x25_hdlc_proto settings;
+};
+
 static int x25_ioctl(struct net_device *dev, struct ifreq *ifr);
 
+static inline struct x25_state* state(hdlc_device *hdlc)

Please no more static inlines in source files. Compiler will know what to do.

Quoted 75 lines
drivers/net/wan/hdlc_x25.c +38 -2
+{
+	return (struct x25_state *)hdlc->state;
+}
+
 /* These functions are callbacks called by LAPB layer */
 
 static void x25_connect_disconnect(struct net_device *dev, int reason, int code)
@@ -186,6 +217,9 @@ static struct hdlc_proto proto = {
 
 static int x25_ioctl(struct net_device *dev, struct ifreq *ifr)
 {
+	x25_hdlc_proto __user *x25_s = ifr->ifr_settings.ifs_ifsu.x25;
+	const size_t size = sizeof(x25_hdlc_proto);
+	x25_hdlc_proto new_settings;
 	hdlc_device *hdlc = dev_to_hdlc(dev);
 	int result;
 
@@ -194,7 +228,13 @@ static int x25_ioctl(struct net_device *dev, struct ifreq *ifr)
 		if (dev_to_hdlc(dev)->proto != &proto)
 			return -EINVAL;
 		ifr->ifr_settings.type = IF_PROTO_X25;
-		return 0; /* return protocol only, no settable parameters */
+		if (ifr->ifr_settings.size < size) {
+			ifr->ifr_settings.size = size; /* data size wanted */
+			return -ENOBUFS;
+		}
+		if (copy_to_user(x25_s, &state(hdlc)->settings, size))
+			return -EFAULT;
+		return 0;
 
 	case IF_PROTO_X25:
 		if (!capable(CAP_NET_ADMIN))
@@ -203,12 +243,35 @@ static int x25_ioctl(struct net_device *dev, struct ifreq *ifr)
 		if (dev->flags & IFF_UP)
 			return -EBUSY;
 
+		if (copy_from_user(&new_settings, x25_s, size))
+			return -EFAULT;
+
+		if ((new_settings.dce != 0 &&
+		     new_settings.dce != 1) ||
+		    (new_settings.modulo != 8 &&
+		     new_settings.modulo != 128) ||
+		    new_settings.window < 1 ||
+		    (new_settings.modulo == 8 &&
+		     new_settings.window > 7) ||
+		    (new_settings.modulo == 128 &&
+		     new_settings.window > 127) ||
+		    new_settings.t1 < 1 ||
+		    new_settings.t1 > 255 ||
+		    new_settings.t2 < 1 ||
+		    new_settings.t2 > 255 ||
+		    new_settings.n2 < 1 ||
+		    new_settings.n2 > 255)
+			return -EINVAL;
+
 		result=hdlc->attach(dev, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT);
 		if (result)
 			return result;
 
-		if ((result = attach_hdlc_protocol(dev, &proto, 0)))
+		if ((result = attach_hdlc_protocol(dev, &proto,
+						   sizeof(struct x25_state))))
 			return result;
+
+		memcpy(&state(hdlc)->settings, &new_settings, size);
 		dev->type = ARPHRD_X25;
 		call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev);
 		netif_dormant_off(dev);
include/uapi/linux/hdlc/ioctl.h +0 -0
index 0fe4238e8246..3656ce8b8af0 100644

include/uapi/linux/hdlc/ioctl.h line 6

Quoted 5 lines
include/uapi/linux/hdlc/ioctl.h +1 -1
@@ -3,7 +3,7 @@
 #define __HDLC_IOCTL_H__
 
 
-#define GENERIC_HDLC_VERSION 4	/* For synchronization with sethdlc utility */
+#define GENERIC_HDLC_VERSION 5	/* For synchronization with sethdlc utility */

What's the backward compatibility story in this code?

The IOCTL handling at least looks like it may start returning errors to existing user space which could have expected the parameters to IF_PROTO_X25 (other than just ifr_settings.type) to be ignored.

Quoted 2 lines
include/uapi/linux/hdlc/ioctl.h +0 -0
 #define CLOCK_DEFAULT   0	/* Default setting */
 #define CLOCK_EXT	1	/* External TX and RX clock - DTE */
author maintainer
#5 lore raw
Quoted 20 lines · Jakub Kicinski
Quoted 19 lines · Martin Schiller

This enables you to configure mode (DTE/DCE), Modulo, Window, T1, T2, N2 via sethdlc (which needs to be patched as well).

drivers/net/wan/hdlc_x25.c +4 -0
index 5643675ff724..b28051eba736 100644
@@ -21,8 +21,17 @@
 #include <linux/skbuff.h>
 #include <net/x25device.h>
 
+struct x25_state {
+	x25_hdlc_proto settings;
+};
+
 static int x25_ioctl(struct net_device *dev, struct ifreq *ifr);
 
Quoted 4 lines

drivers/net/wan/hdlc_x25.c line 30

Quoted 1 line
drivers/net/wan/hdlc_x25.c +1 -0
+static inline struct x25_state* state(hdlc_device *hdlc)

Please no more static inlines in source files. Compiler will know what to do.

OK, i will remove the "inline". I've just used it, because it's also in the hdlc_fr.c and hdlc_cisco.c code.

Quoted 82 lines
Quoted 82 lines
drivers/net/wan/hdlc_x25.c +4 -0
+{
+	return (struct x25_state *)hdlc->state;
+}
+
 /* These functions are callbacks called by LAPB layer */
 
 static void x25_connect_disconnect(struct net_device *dev, int 

reason, int code)

drivers/net/wan/hdlc_x25.c +10 -1
@@ -186,6 +217,9 @@ static struct hdlc_proto proto = {
 
 static int x25_ioctl(struct net_device *dev, struct ifreq *ifr)
 {
+	x25_hdlc_proto __user *x25_s = ifr->ifr_settings.ifs_ifsu.x25;
+	const size_t size = sizeof(x25_hdlc_proto);
+	x25_hdlc_proto new_settings;
 	hdlc_device *hdlc = dev_to_hdlc(dev);
 	int result;
 
@@ -194,7 +228,13 @@ static int x25_ioctl(struct net_device *dev, 
 struct ifreq *ifr)
 		if (dev_to_hdlc(dev)->proto != &proto)
 			return -EINVAL;
 		ifr->ifr_settings.type = IF_PROTO_X25;
-		return 0; /* return protocol only, no settable parameters */
+		if (ifr->ifr_settings.size < size) {
+			ifr->ifr_settings.size = size; /* data size wanted */
+			return -ENOBUFS;
+		}
+		if (copy_to_user(x25_s, &state(hdlc)->settings, size))
+			return -EFAULT;
+		return 0;
 
 	case IF_PROTO_X25:
drivers/net/wan/hdlc_x25.c +24 -1
 		if (!capable(CAP_NET_ADMIN))
@@ -203,12 +243,35 @@ static int x25_ioctl(struct net_device *dev, 
 struct ifreq *ifr)
 		if (dev->flags & IFF_UP)
 			return -EBUSY;
 
+		if (copy_from_user(&new_settings, x25_s, size))
+			return -EFAULT;
+
+		if ((new_settings.dce != 0 &&
+		     new_settings.dce != 1) ||
+		    (new_settings.modulo != 8 &&
+		     new_settings.modulo != 128) ||
+		    new_settings.window < 1 ||
+		    (new_settings.modulo == 8 &&
+		     new_settings.window > 7) ||
+		    (new_settings.modulo == 128 &&
+		     new_settings.window > 127) ||
+		    new_settings.t1 < 1 ||
+		    new_settings.t1 > 255 ||
+		    new_settings.t2 < 1 ||
+		    new_settings.t2 > 255 ||
+		    new_settings.n2 < 1 ||
+		    new_settings.n2 > 255)
+			return -EINVAL;
+
 		result=hdlc->attach(dev, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT);
 		if (result)
 			return result;
 
-		if ((result = attach_hdlc_protocol(dev, &proto, 0)))
+		if ((result = attach_hdlc_protocol(dev, &proto,
+						   sizeof(struct x25_state))))
 			return result;
+
+		memcpy(&state(hdlc)->settings, &new_settings, size);
 		dev->type = ARPHRD_X25;
 		call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev);
drivers/net/wan/hdlc_x25.c +0 -0
 		netif_dormant_off(dev);
include/uapi/linux/hdlc/ioctl.h +0 -0
index 0fe4238e8246..3656ce8b8af0 100644
@@ -3,7 +3,7 @@
 #define __HDLC_IOCTL_H__
 
 
Quoted 6 lines
Quoted 4 lines
include/uapi/linux/hdlc/ioctl.h +0 -1
-#define GENERIC_HDLC_VERSION 4	/* For synchronization with sethdlc 

utility */
+#define GENERIC_HDLC_VERSION 5 /* For synchronization with sethdlc
utility */

What's the backward compatibility story in this code?

Well, I thought I have to increment the version to keep the kernel code and the sethdlc utility in sync (like the comment says).

Quoted 4 lines

The IOCTL handling at least looks like it may start returning errors to existing user space which could have expected the parameters to IF_PROTO_X25 (other than just ifr_settings.type) to be ignored.

I could also try to implement it without incrementing the version by looking at ifr_settings.size and using the former defaults if the size doesn't match.

Quoted 3 lines
Quoted 3 lines

#define CLOCK_DEFAULT 0 /* Default setting */
#define CLOCK_EXT 1 /* External TX and RX clock - DTE */

author maintainer
#3 lore raw

Re: [PATCH 2/2] wan/hdlc_x25: fix skb handling

In reply to Jakub Kicinski
Quoted 11 lines · Jakub Kicinski
Quoted 8 lines · Martin Schiller

o call skb_reset_network_header() before hdlc->xmit()
o change skb proto to HDLC (0x0019) before hdlc->xmit()
o call dev_queue_xmit_nit() before hdlc->xmit()

This changes make it possible to trace (tcpdump) outgoing layer2 (ETH_P_HDLC) packets

o use a copy of the skb for lapb_data_request() in x25_xmit()

It's not clear to me why

Well, this patch is ported form an older environment which is based on linux-3.4. I can't reproduce the misbehavior with actual version, so I will drop this part of the patch.

Quoted 17 lines
Quoted 17 lines

This fixes the problem, that tracing layer3 (ETH_P_X25) packets results in a malformed first byte of the packets.

---
 drivers/net/wan/hdlc_x25.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/wan/hdlc_x25.c +0 -0
index b28051eba736..434e5263eddf 100644
@@ -72,6 +72,7 @@ static int x25_data_indication(struct net_device 
 *dev, struct sk_buff *skb)
 	unsigned char *ptr;
 
Quoted 8 lines

drivers/net/wan/hdlc_x25.c static int x25_data_indication(struct net_device *dev, struct sk_buff *skb) · line 77

Quoted 4 lines
drivers/net/wan/hdlc_x25.c +1 -0
 	skb_push(skb, 1);
+	skb_reset_network_header(skb);
 
 	if (skb_cow(skb, 1))

This skb_cow() here is for the next handler down to have a 1 byte of headroom guaranteed? It'd seem more natural to have skb_cow before the push.. not that it's related to your patch.

Thanks for the hint. I will move the skb_cow() before the skb_push().

Quoted 11 lines

drivers/net/wan/hdlc_x25.c static int x25_data_indication(struct net_device · line 93

Quoted 8 lines
drivers/net/wan/hdlc_x25.c +0 -0
 		return NET_RX_DROP;
@@ -88,6 +89,9 @@ static int x25_data_indication(struct net_device 
 *dev, struct sk_buff *skb)
 static void x25_data_transmit(struct net_device *dev, struct sk_buff 
 *skb)
 {
 	hdlc_device *hdlc = dev_to_hdlc(dev);

Please insert a new line after the variable declaration since you're touching this one.

OK, will do.

Quoted 3 lines

drivers/net/wan/hdlc_x25.c static int x25_data_indication(struct net_device *dev, struct sk_buff *skb) · line 93

Quoted 3 lines
drivers/net/wan/hdlc_x25.c +2 -0
+	skb_reset_network_header(skb);
+	skb->protocol = hdlc_type_trans(skb, dev);

I will also insert an "if (dev_nit_active(dev))" here.

Quoted 4 lines
Quoted 4 lines
drivers/net/wan/hdlc_x25.c +1 -0
+	dev_queue_xmit_nit(skb, dev);
 	hdlc->xmit(skb, dev); /* Ignore return value :-( */

}

#6 lore raw
In reply to Martin Schiller
Quoted 16 lines · Martin Schiller
Quoted 9 lines
Quoted 9 lines
include/uapi/linux/hdlc/ioctl.h +0 -0
index 0fe4238e8246..3656ce8b8af0 100644
@@ -3,7 +3,7 @@
 #define __HDLC_IOCTL_H__
 
 
Quoted 6 lines
Quoted 4 lines
include/uapi/linux/hdlc/ioctl.h +0 -1
-#define GENERIC_HDLC_VERSION 4	/* For synchronization with sethdlc 

utility */
+#define GENERIC_HDLC_VERSION 5 /* For synchronization with sethdlc
utility */

What's the backward compatibility story in this code?

Quoted 2 lines

Well, I thought I have to increment the version to keep the kernel code and the sethdlc utility in sync (like the comment says).

Perhaps I chose the wrong place for asking this question, IOCTL code was my real worry. I don't think this version number is validated so I think bumping it shouldn't break anything?

Quoted 7 lines
Quoted 3 lines

The IOCTL handling at least looks like it may start returning errors to existing user space which could have expected the parameters to IF_PROTO_X25 (other than just ifr_settings.type) to be ignored.

I could also try to implement it without incrementing the version by looking at ifr_settings.size and using the former defaults if the size doesn't match.

Sounds good, thank you!

author maintainer
#7 lore raw
Quoted 17 lines · Jakub Kicinski
Quoted 16 lines · Martin Schiller
Quoted 15 lines
Quoted 10 lines
include/uapi/linux/hdlc/ioctl.h +0 -1
index 0fe4238e8246..3656ce8b8af0 100644
@@ -3,7 +3,7 @@
 #define __HDLC_IOCTL_H__
 
 
-#define GENERIC_HDLC_VERSION 4	/* For synchronization with sethdlc
Quoted 3 lines

utility */
+#define GENERIC_HDLC_VERSION 5 /* For synchronization with sethdlc
utility */

What's the backward compatibility story in this code?

Quoted 6 lines
Quoted 2 lines

Well, I thought I have to increment the version to keep the kernel code and the sethdlc utility in sync (like the comment says).

Perhaps I chose the wrong place for asking this question, IOCTL code was my real worry. I don't think this version number is validated so I think bumping it shouldn't break anything?

sethdlc validates the GENERIC_HDLC_VERSION at compile time.

https://mirrors.edge.kernel.org/pub/linux/utils/net/hdlc/

Another question:
Where do I have to send my patch for sethdlc to?

Quoted 10 lines
Quoted 8 lines
Quoted 4 lines

The IOCTL handling at least looks like it may start returning errors to existing user space which could have expected the parameters to IF_PROTO_X25 (other than just ifr_settings.type) to be ignored.

I could also try to implement it without incrementing the version by looking at ifr_settings.size and using the former defaults if the size doesn't match.

Sounds good, thank you!

OK, I will send a v2 of the patch.

#8 lore raw
Quoted 22 lines · Martin Schiller
Quoted 21 lines · Jakub Kicinski
Quoted 19 lines · Martin Schiller
Quoted 9 lines
Quoted 9 lines
include/uapi/linux/hdlc/ioctl.h +0 -0
index 0fe4238e8246..3656ce8b8af0 100644
@@ -3,7 +3,7 @@
 #define __HDLC_IOCTL_H__
 
 
Quoted 6 lines
Quoted 4 lines
include/uapi/linux/hdlc/ioctl.h +0 -1
-#define GENERIC_HDLC_VERSION 4	/* For synchronization with sethdlc

utility */
+#define GENERIC_HDLC_VERSION 5 /* For synchronization with sethdlc
utility */

What's the backward compatibility story in this code?

Well, I thought I have to increment the version to keep the kernel code
and the sethdlc utility in sync (like the comment says).

Quoted 7 lines
Quoted 3 lines

Perhaps I chose the wrong place for asking this question, IOCTL code was my real worry. I don't think this version number is validated so I think bumping it shouldn't break anything?

sethdlc validates the GENERIC_HDLC_VERSION at compile time.

https://mirrors.edge.kernel.org/pub/linux/utils/net/hdlc/

Aw, okay, best not to bump it then.

Quoted 2 lines

Another question:
Where do I have to send my patch for sethdlc to?

No idea :)

#9 lore raw
In reply to Martin Schiller

Hi,

I overlooked this mail, sorry.

Quoted 6 lines · Martin Schiller

sethdlc validates the GENERIC_HDLC_VERSION at compile time.

https://mirrors.edge.kernel.org/pub/linux/utils/net/hdlc/

Another question:
Where do I have to send my patch for sethdlc to?

I guess you have to put your own version somewhere. I don't have access to hdlc directory at kernel.org anymore, this stuff (sync serial with HDLC) is no longer in use around here.

Signature · 5 lines
Krzysztof Halasa

ŁUKASIEWICZ Research Network
Industrial Research Institute for Automation and Measurements PIAP
Al. Jerozolimskie 202, 02-486 Warsaw, Poland