From 121caf577dc61588c1128821873a08cec48baf58 Mon Sep 17 00:00:00 2001 From: Nishanth Aravamudan Date: Mon, 12 Sep 2005 14:15:34 -0700 Subject: [NET]: fix-up schedule_timeout() usage Use schedule_timeout_{,un}interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size. Also use human-time conversion functions instead of hard-coded division to avoid rounding issues. Signed-off-by: Nishanth Aravamudan Signed-off-by: Andrew Morton Signed-off-by: David S. Miller --- net/core/pktgen.c | 13 +++++-------- net/ipv4/ipconfig.c | 6 ++---- net/irda/ircomm/ircomm_tty.c | 9 +++------ net/sunrpc/svcsock.c | 3 +-- 4 files changed, 11 insertions(+), 20 deletions(-) (limited to 'net') diff --git a/net/core/pktgen.c b/net/core/pktgen.c index b3ad49fa7d78..ef430b1e8e42 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -1452,8 +1452,7 @@ static int proc_thread_write(struct file *file, const char __user *user_buffer, thread_lock(); t->control |= T_REMDEV; thread_unlock(); - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(HZ/8); /* Propagate thread->control */ + schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */ ret = count; sprintf(pg_result, "OK: rem_device_all"); goto out; @@ -1716,10 +1715,9 @@ static void spin(struct pktgen_dev *pkt_dev, __u64 spin_until_us) printk(KERN_INFO "sleeping for %d\n", (int)(spin_until_us - now)); while (now < spin_until_us) { /* TODO: optimise sleeping behavior */ - if (spin_until_us - now > (1000000/HZ)+1) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(1); - } else if (spin_until_us - now > 100) { + if (spin_until_us - now > jiffies_to_usecs(1)+1) + schedule_timeout_interruptible(1); + else if (spin_until_us - now > 100) { do_softirq(); if (!pkt_dev->running) return; @@ -2449,8 +2447,7 @@ static void pktgen_run_all_threads(void) } thread_unlock(); - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(HZ/8); /* Propagate thread->control */ + schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */ pktgen_wait_all_threads_run(); } diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 953129d392d2..e8674baaa8d9 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -1103,10 +1103,8 @@ static int __init ic_dynamic(void) #endif jiff = jiffies + (d->next ? CONF_INTER_TIMEOUT : timeout); - while (time_before(jiffies, jiff) && !ic_got_reply) { - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(1); - } + while (time_before(jiffies, jiff) && !ic_got_reply) + schedule_timeout_uninterruptible(1); #ifdef IPCONFIG_DHCP /* DHCP isn't done until we get a DHCPACK. */ if ((ic_got_reply & IC_BOOTP) diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index 5d1e61168eb7..6f20b4206e08 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c @@ -567,10 +567,8 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp) self->tty = NULL; if (self->blocked_open) { - if (self->close_delay) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(self->close_delay); - } + if (self->close_delay) + schedule_timeout_interruptible(self->close_delay); wake_up_interruptible(&self->open_wait); } @@ -863,8 +861,7 @@ static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout) spin_lock_irqsave(&self->spinlock, flags); while (self->tx_skb && self->tx_skb->len) { spin_unlock_irqrestore(&self->spinlock, flags); - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(poll_time); + schedule_timeout_interruptible(poll_time); spin_lock_irqsave(&self->spinlock, flags); if (signal_pending(current)) break; diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 05fe2e735538..51885b5f744e 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -1170,8 +1170,7 @@ svc_recv(struct svc_serv *serv, struct svc_rqst *rqstp, long timeout) while (rqstp->rq_arghi < pages) { struct page *p = alloc_page(GFP_KERNEL); if (!p) { - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ/2); + schedule_timeout_uninterruptible(msecs_to_jiffies(500)); continue; } rqstp->rq_argpages[rqstp->rq_arghi++] = p; -- cgit v1.2.2 From 59c2353dd045509626d7cc1953cb2d6b7358ab7a Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 12 Sep 2005 14:16:58 -0700 Subject: [CCID3]: Listen socks doesn't have a private CCID block Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- net/dccp/ccids/ccid3.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'net') diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index e05f4f955eee..38aa84986118 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -1095,6 +1095,10 @@ static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) { const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); + /* Listen socks doesn't have a private CCID block */ + if (sk->sk_state == DCCP_LISTEN) + return; + BUG_ON(hcrx == NULL); info->tcpi_ca_state = hcrx->ccid3hcrx_state; @@ -1106,6 +1110,10 @@ static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info) { const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); + /* Listen socks doesn't have a private CCID block */ + if (sk->sk_state == DCCP_LISTEN) + return; + BUG_ON(hctx == NULL); info->tcpi_rto = hctx->ccid3hctx_t_rto; -- cgit v1.2.2 From 6f74998e5c3b4610e6eba06babf16547369c512a Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 12 Sep 2005 14:21:01 -0700 Subject: [AX.25]: Rename ax25_encapsulate to ax25_hard_header Rename ax25_encapsulate to ax25_hard_header which these days more accurately describes what the function is supposed to do. Signed-off-by: Ralf Baechle DL5RB Signed-off-by: David S. Miller --- net/ax25/af_ax25.c | 2 +- net/ax25/ax25_ip.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'net') diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index ed705ddad56b..17f192b77867 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -1984,7 +1984,7 @@ static struct notifier_block ax25_dev_notifier = { .notifier_call =ax25_device_event, }; -EXPORT_SYMBOL(ax25_encapsulate); +EXPORT_SYMBOL(ax25_hard_header); EXPORT_SYMBOL(ax25_rebuild_header); EXPORT_SYMBOL(ax25_findbyuid); EXPORT_SYMBOL(ax25_find_cb); diff --git a/net/ax25/ax25_ip.c b/net/ax25/ax25_ip.c index bba0173e2d65..d643dac3eccc 100644 --- a/net/ax25/ax25_ip.c +++ b/net/ax25/ax25_ip.c @@ -47,7 +47,7 @@ #ifdef CONFIG_INET -int ax25_encapsulate(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len) +int ax25_hard_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len) { unsigned char *buff; @@ -88,7 +88,7 @@ int ax25_encapsulate(struct sk_buff *skb, struct net_device *dev, unsigned short *buff++ = AX25_P_ARP; break; default: - printk(KERN_ERR "AX.25: ax25_encapsulate - wrong protocol type 0x%2.2x\n", type); + printk(KERN_ERR "AX.25: ax25_hard_header - wrong protocol type 0x%2.2x\n", type); *buff++ = 0; break; } @@ -209,7 +209,7 @@ put: #else /* INET */ -int ax25_encapsulate(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len) +int ax25_hard_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len) { return -AX25_HEADER_LEN; } -- cgit v1.2.2 From 3f2aadd041a7a3e732d182c3770b3fa95a2300b2 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 12 Sep 2005 14:21:48 -0700 Subject: [NETROM]: Fix rebuild header mess For reason that probably nobody recalls NET/ROM does it's actual packet transmission in nr_rebuild_header and even treats invocation of it's hard_start_xmit method nr_xmit as a bug. Fix that by splitting the job done by nr_rebuild_header into two halves. Along with that we now also can get rid of the silly clone of the skb on transmit. Signed-off-by: Ralf Baechle DL5RB Signed-off-by: David S. Miller --- net/netrom/nr_dev.c | 44 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) (limited to 'net') diff --git a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c index 263da4c26494..431a25384421 100644 --- a/net/netrom/nr_dev.c +++ b/net/netrom/nr_dev.c @@ -71,15 +71,10 @@ int nr_rx_ip(struct sk_buff *skb, struct net_device *dev) static int nr_rebuild_header(struct sk_buff *skb) { - struct net_device *dev = skb->dev; - struct net_device_stats *stats = netdev_priv(dev); - struct sk_buff *skbn; unsigned char *bp = skb->data; - int len; - if (arp_find(bp + 7, skb)) { + if (arp_find(bp + 7, skb)) return 1; - } bp[6] &= ~AX25_CBIT; bp[6] &= ~AX25_EBIT; @@ -90,27 +85,7 @@ static int nr_rebuild_header(struct sk_buff *skb) bp[6] |= AX25_EBIT; bp[6] |= AX25_SSSID_SPARE; - if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL) { - kfree_skb(skb); - return 1; - } - - if (skb->sk != NULL) - skb_set_owner_w(skbn, skb->sk); - - kfree_skb(skb); - - len = skbn->len; - - if (!nr_route_frame(skbn, NULL)) { - kfree_skb(skbn); - stats->tx_errors++; - } - - stats->tx_packets++; - stats->tx_bytes += len; - - return 1; + return 0; } #else @@ -186,8 +161,19 @@ static int nr_close(struct net_device *dev) static int nr_xmit(struct sk_buff *skb, struct net_device *dev) { struct net_device_stats *stats = netdev_priv(dev); - dev_kfree_skb(skb); - stats->tx_errors++; + unsigned int len; + + len = skb->len; + + if (!nr_route_frame(skb, NULL)) { + kfree_skb(skb); + stats->tx_errors++; + return 0; + } + + stats->tx_packets++; + stats->tx_bytes += len; + return 0; } -- cgit v1.2.2 From 6ddcf626fd0a3cbf410ceb483cb76074ed1c5873 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 12 Sep 2005 14:23:06 -0700 Subject: [NETROM]: statistics fix Calling an incoming NET/ROM-encapsulated IP packet an error if the interface isn't up is probably a bit over the top, so count it as dropped instead of an error. Signed-off-by: Ralf Baechle DL5RB Signed-off-by: David S. Miller --- net/netrom/nr_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net') diff --git a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c index 431a25384421..4c6a9851ca6e 100644 --- a/net/netrom/nr_dev.c +++ b/net/netrom/nr_dev.c @@ -47,7 +47,7 @@ int nr_rx_ip(struct sk_buff *skb, struct net_device *dev) struct net_device_stats *stats = netdev_priv(dev); if (!netif_running(dev)) { - stats->rx_errors++; + stats->rx_dropped++; return 0; } -- cgit v1.2.2 From 9b37ee75858ce35cf3c0e4724acaf4efabb45687 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 12 Sep 2005 14:23:52 -0700 Subject: [NETROM/AX.25/ROSE]: Remove useless tests Remove error tests that have already been performed by the caller. Signed-off-by: Ralf Baechle DL5RB Signed-off-by: David S. Miller --- net/ax25/af_ax25.c | 6 +----- net/netrom/af_netrom.c | 4 +--- net/rose/af_rose.c | 4 +--- 3 files changed, 3 insertions(+), 11 deletions(-) (limited to 'net') diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 17f192b77867..9c487311e0a9 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -1700,11 +1700,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) } case SIOCGSTAMP: - if (sk != NULL) { - res = sock_get_timestamp(sk, argp); - break; - } - res = -EINVAL; + res = sock_get_timestamp(sk, argp); break; case SIOCAX25ADDUID: /* Add a uid to the uid/call map table */ diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index f4578c759ffc..02b1ab52dbbf 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -1187,9 +1187,7 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) } case SIOCGSTAMP: - ret = -EINVAL; - if (sk != NULL) - ret = sock_get_timestamp(sk, argp); + ret = sock_get_timestamp(sk, argp); release_sock(sk); return ret; diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 3077878ed4f0..977f99a9cfc0 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c @@ -1256,9 +1256,7 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) } case SIOCGSTAMP: - if (sk != NULL) - return sock_get_timestamp(sk, (struct timeval __user *)argp); - return -EINVAL; + return sock_get_timestamp(sk, (struct timeval __user *)argp); case SIOCGIFADDR: case SIOCSIFADDR: -- cgit v1.2.2 From 20b7d10a3339cbfa2f7a52da0ad77b5a0723f0ca Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 12 Sep 2005 14:24:55 -0700 Subject: [AX.25/ROSE]: Whitespace formatting changes Small formatting changes. Signed-off-by: Ralf Baechle DL5RB Signed-off-by: David S. Miller --- net/ax25/af_ax25.c | 2 +- net/rose/af_rose.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'net') diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 9c487311e0a9..7023532beeff 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -1695,7 +1695,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) /* These two are safe on a single CPU system as only user tasks fiddle here */ if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) amount = skb->len; - res = put_user(amount, (int __user *)argp); + res = put_user(amount, (int __user *) argp); break; } diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 977f99a9cfc0..5acb1680524a 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c @@ -1243,7 +1243,7 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc); if (amount < 0) amount = 0; - return put_user(amount, (unsigned int __user *)argp); + return put_user(amount, (unsigned int __user *) argp); } case TIOCINQ: { @@ -1252,11 +1252,11 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) /* These two are safe on a single CPU system as only user tasks fiddle here */ if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) amount = skb->len; - return put_user(amount, (unsigned int __user *)argp); + return put_user(amount, (unsigned int __user *) argp); } case SIOCGSTAMP: - return sock_get_timestamp(sk, (struct timeval __user *)argp); + return sock_get_timestamp(sk, (struct timeval __user *) argp); case SIOCGIFADDR: case SIOCSIFADDR: -- cgit v1.2.2 From 4676356b57ee767d5a95df8270f5c372b838dd33 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 12 Sep 2005 14:25:25 -0700 Subject: [AX.25]: Reformat ax25_proto_ops initialization Reformat iniitalization of ax25_proto_ops. Signed-off-by: Ralf Baechle DL5RB Signed-off-by: David S. Miller --- net/ax25/af_ax25.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'net') diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 7023532beeff..8e37e71e34ff 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -1947,24 +1947,24 @@ static struct net_proto_family ax25_family_ops = { }; static struct proto_ops ax25_proto_ops = { - .family = PF_AX25, - .owner = THIS_MODULE, - .release = ax25_release, - .bind = ax25_bind, - .connect = ax25_connect, - .socketpair = sock_no_socketpair, - .accept = ax25_accept, - .getname = ax25_getname, - .poll = datagram_poll, - .ioctl = ax25_ioctl, - .listen = ax25_listen, - .shutdown = ax25_shutdown, - .setsockopt = ax25_setsockopt, - .getsockopt = ax25_getsockopt, - .sendmsg = ax25_sendmsg, - .recvmsg = ax25_recvmsg, - .mmap = sock_no_mmap, - .sendpage = sock_no_sendpage, + .family = PF_AX25, + .owner = THIS_MODULE, + .release = ax25_release, + .bind = ax25_bind, + .connect = ax25_connect, + .socketpair = sock_no_socketpair, + .accept = ax25_accept, + .getname = ax25_getname, + .poll = datagram_poll, + .ioctl = ax25_ioctl, + .listen = ax25_listen, + .shutdown = ax25_shutdown, + .setsockopt = ax25_setsockopt, + .getsockopt = ax25_getsockopt, + .sendmsg = ax25_sendmsg, + .recvmsg = ax25_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; /* -- cgit v1.2.2 From dd8aa40431d2776ef72fd36aab6a6a6bf0f45967 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 12 Sep 2005 14:25:57 -0700 Subject: [NETROM] NET/ROM has no txqueue NET/ROM uses virtual interfaces so setting a queue length is wrong. Signed-off-by: Ralf Baechle DL5RB Signed-off-by: David S. Miller --- net/netrom/nr_dev.c | 1 - 1 file changed, 1 deletion(-) (limited to 'net') diff --git a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c index 4c6a9851ca6e..0559cc07ecd8 100644 --- a/net/netrom/nr_dev.c +++ b/net/netrom/nr_dev.c @@ -194,7 +194,6 @@ void nr_setup(struct net_device *dev) dev->hard_header_len = NR_NETWORK_LEN + NR_TRANSPORT_LEN; dev->addr_len = AX25_ADDR_LEN; dev->type = ARPHRD_NETROM; - dev->tx_queue_len = 40; dev->rebuild_header = nr_rebuild_header; dev->set_mac_address = nr_set_mac_address; -- cgit v1.2.2 From 723772913e6caf82919754f9d73fa55fc762bb1b Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 12 Sep 2005 14:26:26 -0700 Subject: [NETROM]: NET/ROM has no ARP ARP over NET/ROM does not exist so it's obviously not implemented on any NET/ROM stack, so the NET/ROM interfaces really should default to IFF_NOARP. Signed-off-by: Ralf Baechle DL5RB Signed-off-by: David S. Miller --- net/netrom/nr_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net') diff --git a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c index 0559cc07ecd8..909aa7f50744 100644 --- a/net/netrom/nr_dev.c +++ b/net/netrom/nr_dev.c @@ -198,7 +198,7 @@ void nr_setup(struct net_device *dev) dev->set_mac_address = nr_set_mac_address; /* New-style flags. */ - dev->flags = 0; + dev->flags = IFF_NOARP; dev->get_stats = nr_get_stats; } -- cgit v1.2.2 From d2ce4bc340946d5b78484d638ac10df958c4c3bf Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 12 Sep 2005 14:26:52 -0700 Subject: [ROSE]: ROSE has no ARP ARP over ROSE does not exist so it's obviously not implemented on any ROSE stack, so the ROSE interfaces really should default to IFF_NOARP. Signed-off-by: Ralf Baechle DL5RB Signed-off-by: David S. Miller --- net/rose/rose_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net') diff --git a/net/rose/rose_dev.c b/net/rose/rose_dev.c index a8ed9a1d09f9..d297af737d10 100644 --- a/net/rose/rose_dev.c +++ b/net/rose/rose_dev.c @@ -149,6 +149,6 @@ void rose_setup(struct net_device *dev) dev->set_mac_address = rose_set_mac_address; /* New-style flags. */ - dev->flags = 0; + dev->flags = IFF_NOARP; dev->get_stats = rose_get_stats; } -- cgit v1.2.2 From e21ce8c7c013fb223a002c70bb0a547de6c26c12 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 12 Sep 2005 14:27:37 -0700 Subject: [NETROM]: Implement G8PZT Circuit reset for NET/ROM NET/ROM is lacking a connection reset like TCP's RST flag which at times may result in a connecting having to slowly timing out instead of just being reset. An earlier attempt to reset the connection by sending a NR_CONNACK | NR_CHOKE_FLAG transport was inacceptable as it did result in crashes of BPQ systems. An alternative approach of introducing a new transport type 7 (NR_RESET) has be implemented several years ago in Paula Jayne Dowie G8PZT's Xrouter. Implement NR_RESET for Linux's NET/ROM but like any messing with the state engine consider this experimental for now and thus control it by a sysctl (net.netrom.reset) which for the time being defaults to off. Signed-off-by: Ralf Baechle DL5RB Signed-off-by: David S. Miller --- net/netrom/af_netrom.c | 21 +++++++++++---------- net/netrom/nr_in.c | 15 +++++++++++++++ net/netrom/nr_subr.c | 7 +++---- net/netrom/sysctl_net_netrom.c | 12 ++++++++++++ 4 files changed, 41 insertions(+), 14 deletions(-) (limited to 'net') diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 02b1ab52dbbf..8c3d3a78481e 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -56,6 +56,7 @@ int sysctl_netrom_transport_requested_window_size = NR_DEFAULT_WINDOW; int sysctl_netrom_transport_no_activity_timeout = NR_DEFAULT_IDLE; int sysctl_netrom_routing_control = NR_DEFAULT_ROUTING; int sysctl_netrom_link_fails_count = NR_DEFAULT_FAILS; +int sysctl_netrom_reset_circuit = NR_DEFAULT_RESET; static unsigned short circuit = 0x101; @@ -908,17 +909,17 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev) if (frametype != NR_CONNREQ) { /* * Here it would be nice to be able to send a reset but - * NET/ROM doesn't have one. The following hack would - * have been a way to extend the protocol but apparently - * it kills BPQ boxes... :-( + * NET/ROM doesn't have one. We've tried to extend the protocol + * by sending NR_CONNACK | NR_CHOKE_FLAGS replies but that + * apparently kills BPQ boxes... :-( + * So now we try to follow the established behaviour of + * G8PZT's Xrouter which is sending packets with command type 7 + * as an extension of the protocol. */ -#if 0 - /* - * Never reply to a CONNACK/CHOKE. - */ - if (frametype != NR_CONNACK || flags != NR_CHOKE_FLAG) - nr_transmit_refusal(skb, 1); -#endif + if (sysctl_netrom_reset_circuit && + (frametype != NR_RESET || flags != 0)) + nr_transmit_reset(skb, 1); + return 0; } diff --git a/net/netrom/nr_in.c b/net/netrom/nr_in.c index 64b81a796907..004e8599b8fe 100644 --- a/net/netrom/nr_in.c +++ b/net/netrom/nr_in.c @@ -98,6 +98,11 @@ static int nr_state1_machine(struct sock *sk, struct sk_buff *skb, nr_disconnect(sk, ECONNREFUSED); break; + case NR_RESET: + if (sysctl_netrom_reset_circuit); + nr_disconnect(sk, ECONNRESET); + break; + default: break; } @@ -124,6 +129,11 @@ static int nr_state2_machine(struct sock *sk, struct sk_buff *skb, nr_disconnect(sk, 0); break; + case NR_RESET: + if (sysctl_netrom_reset_circuit); + nr_disconnect(sk, ECONNRESET); + break; + default: break; } @@ -254,6 +264,11 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype } break; + case NR_RESET: + if (sysctl_netrom_reset_circuit); + nr_disconnect(sk, ECONNRESET); + break; + default: break; } diff --git a/net/netrom/nr_subr.c b/net/netrom/nr_subr.c index 587bed2674bf..bcb9946b4f56 100644 --- a/net/netrom/nr_subr.c +++ b/net/netrom/nr_subr.c @@ -210,10 +210,9 @@ void nr_write_internal(struct sock *sk, int frametype) } /* - * This routine is called when a Connect Acknowledge with the Choke Flag - * set is needed to refuse a connection. + * This routine is called to send an error reply. */ -void nr_transmit_refusal(struct sk_buff *skb, int mine) +void __nr_transmit_reply(struct sk_buff *skb, int mine, unsigned char cmdflags) { struct sk_buff *skbn; unsigned char *dptr; @@ -254,7 +253,7 @@ void nr_transmit_refusal(struct sk_buff *skb, int mine) *dptr++ = 0; } - *dptr++ = NR_CONNACK | NR_CHOKE_FLAG; + *dptr++ = cmdflags; *dptr++ = 0; if (!nr_route_frame(skbn, NULL)) diff --git a/net/netrom/sysctl_net_netrom.c b/net/netrom/sysctl_net_netrom.c index c9ed50382ea7..6bb8dda849dc 100644 --- a/net/netrom/sysctl_net_netrom.c +++ b/net/netrom/sysctl_net_netrom.c @@ -30,6 +30,7 @@ static int min_idle[] = {0 * HZ}; static int max_idle[] = {65535 * HZ}; static int min_route[] = {0}, max_route[] = {1}; static int min_fails[] = {1}, max_fails[] = {10}; +static int min_reset[] = {0}, max_reset[] = {1}; static struct ctl_table_header *nr_table_header; @@ -155,6 +156,17 @@ static ctl_table nr_table[] = { .extra1 = &min_fails, .extra2 = &max_fails }, + { + .ctl_name = NET_NETROM_RESET, + .procname = "reset", + .data = &sysctl_netrom_reset_circuit, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec_minmax, + .strategy = &sysctl_intvec, + .extra1 = &min_reset, + .extra2 = &max_reset + }, { .ctl_name = 0 } }; -- cgit v1.2.2 From b88a762b6062f06d431af0045de4854a758646c0 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 12 Sep 2005 14:28:03 -0700 Subject: [NETROM]: Introduct stuct nr_private NET/ROM's virtual interfaces don't have a proper private data structure yet. Create struct nr_private and put the statistics there. Signed-off-by: Ralf Baechle DL5RB Signed-off-by: David S. Miller --- net/netrom/af_netrom.c | 3 +-- net/netrom/nr_dev.c | 11 ++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'net') diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 8c3d3a78481e..e5d82d711cae 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -1392,8 +1392,7 @@ static int __init nr_proto_init(void) struct net_device *dev; sprintf(name, "nr%d", i); - dev = alloc_netdev(sizeof(struct net_device_stats), name, - nr_setup); + dev = alloc_netdev(sizeof(struct nr_private), name, nr_setup); if (!dev) { printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device structure\n"); goto fail; diff --git a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c index 909aa7f50744..4e66eef9a034 100644 --- a/net/netrom/nr_dev.c +++ b/net/netrom/nr_dev.c @@ -160,10 +160,9 @@ static int nr_close(struct net_device *dev) static int nr_xmit(struct sk_buff *skb, struct net_device *dev) { - struct net_device_stats *stats = netdev_priv(dev); - unsigned int len; - - len = skb->len; + struct nr_private *nr = netdev_priv(dev); + struct net_device_stats *stats = &nr->stats; + unsigned int len = skb->len; if (!nr_route_frame(skb, NULL)) { kfree_skb(skb); @@ -179,7 +178,9 @@ static int nr_xmit(struct sk_buff *skb, struct net_device *dev) static struct net_device_stats *nr_get_stats(struct net_device *dev) { - return netdev_priv(dev); + struct nr_private *nr = netdev_priv(dev); + + return &nr->stats; } void nr_setup(struct net_device *dev) -- cgit v1.2.2