From 5dbaaa44cd6bd132a7faf3b14a3e4267fdba9408 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Thu, 7 Aug 2003 02:58:15 -0700 Subject: [PPP]: Fix two bugs wrt. compression/decompression. This patch fixes two bugs that were stopping PPP compression (and in particular, Deflate compression) from working. The first bug was pointed out by Richard Moats. In the conversion to use pskb_may_pull, we ended up with a bogus test which basically meant that the kernel driver never saw the CCP conf-ack packets and thus never enabled compression. The second bug crept in with the change of DEFLATE_MIN_SIZE from 8 to 9. Changing that definition had the unfortunate side-effect of changing the way that the code interpreted the encoded Deflate parameter bytes. This meant that we were using the wrong window size, twice what we had actually negotiated with the peer. --- include/linux/ppp-comp.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include/linux') diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h index 82dd01c38920..7227e653b3be 100644 --- a/include/linux/ppp-comp.h +++ b/include/linux/ppp-comp.h @@ -185,10 +185,9 @@ struct compressor { #define DEFLATE_MIN_SIZE 9 #define DEFLATE_MAX_SIZE 15 #define DEFLATE_METHOD_VAL 8 -#define DEFLATE_SIZE(x) (((x) >> 4) + DEFLATE_MIN_SIZE) +#define DEFLATE_SIZE(x) (((x) >> 4) + 8) #define DEFLATE_METHOD(x) ((x) & 0x0F) -#define DEFLATE_MAKE_OPT(w) ((((w) - DEFLATE_MIN_SIZE) << 4) \ - + DEFLATE_METHOD_VAL) +#define DEFLATE_MAKE_OPT(w) ((((w) - 8) << 4) + DEFLATE_METHOD_VAL) #define DEFLATE_CHK_SEQUENCE 0 /* -- cgit v1.2.3 From 97ddbec421eb42de70f3e4a222bc18c2c9717faa Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Thu, 7 Aug 2003 07:05:00 -0700 Subject: [XFRM_USER]: Add inner family field to all SAs and templates. --- include/linux/xfrm.h | 3 ++- net/xfrm/xfrm_user.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'include/linux') diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h index a4dd169d9f6f..430370b12d13 100644 --- a/include/linux/xfrm.h +++ b/include/linux/xfrm.h @@ -37,6 +37,7 @@ struct xfrm_selector __u16 dport_mask; __u16 sport; __u16 sport_mask; + __u16 family; __u8 prefixlen_d; __u8 prefixlen_s; __u8 proto; @@ -125,6 +126,7 @@ enum struct xfrm_user_tmpl { struct xfrm_id id; + __u16 family; xfrm_address_t saddr; __u32 reqid; __u8 mode; @@ -189,7 +191,6 @@ struct xfrm_userpolicy_info { struct xfrm_lifetime_cur curlft; __u32 priority; __u32 index; - __u16 family; __u8 dir; __u8 action; #define XFRM_POLICY_ALLOW 0 diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index b1c87c9924f2..049c7c833d95 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -527,7 +527,7 @@ static int verify_newpolicy_info(struct xfrm_userpolicy_info *p) return -EINVAL; }; - switch (p->family) { + switch (p->sel.family) { case AF_INET: break; @@ -594,7 +594,7 @@ static void copy_from_user_policy(struct xfrm_policy *xp, struct xfrm_userpolicy memcpy(&xp->lft, &p->lft, sizeof(xp->lft)); xp->action = p->action; xp->flags = p->flags; - xp->family = p->family; + xp->family = p->sel.family; /* XXX xp->share = p->share; */ } @@ -605,7 +605,7 @@ static void copy_to_user_policy(struct xfrm_policy *xp, struct xfrm_userpolicy_i memcpy(&p->curlft, &xp->curlft, sizeof(p->curlft)); p->priority = xp->priority; p->index = xp->index; - p->family = xp->family; + p->sel.family = xp->family; p->dir = dir; p->action = xp->action; p->flags = xp->flags; -- cgit v1.2.3 From c891ba69b58709a1b36dc0477bc3755d13b1b555 Mon Sep 17 00:00:00 2001 From: Hideaki Yoshifuji Date: Fri, 8 Aug 2003 11:12:53 -0700 Subject: [IPV6]: Fix typo in linux/ipv6.h --- include/linux/ipv6.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 49207c629e4f..e4f91218676d 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -71,7 +71,7 @@ struct rt0_hdr { __u32 bitmap; /* strict/loose bit map */ struct in6_addr addr[0]; -#define rt0_type rt_hdr.type; +#define rt0_type rt_hdr.type }; struct ipv6_auth_hdr { -- cgit v1.2.3 From 3a6045ffd2e18ba39cd66dddba8fd3b0bccc1681 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 8 Aug 2003 11:19:29 -0700 Subject: [NET]: Fix tun driver to use private linked lists. --- drivers/net/tun.c | 79 ++++++++++++++++++++++++++++++-------------------- include/linux/if_tun.h | 2 +- 2 files changed, 49 insertions(+), 32 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 53097e3fa392..3fdb10227fe7 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -51,6 +51,8 @@ static int debug; /* Network device part of the driver */ +static LIST_HEAD(tun_dev_list); + /* Net device open. */ static int tun_net_open(struct net_device *dev) { @@ -70,7 +72,7 @@ static int tun_net_xmit(struct sk_buff *skb, struct net_device *dev) { struct tun_struct *tun = (struct tun_struct *)dev->priv; - DBG(KERN_INFO "%s: tun_net_xmit %d\n", tun->name, skb->len); + DBG(KERN_INFO "%s: tun_net_xmit %d\n", tun->dev->name, skb->len); /* Drop packet if interface is not attached */ if (!tun->attached) @@ -120,7 +122,7 @@ int tun_net_init(struct net_device *dev) { struct tun_struct *tun = (struct tun_struct *)dev->priv; - DBG(KERN_INFO "%s: tun_net_init\n", tun->name); + DBG(KERN_INFO "%s: tun_net_init\n", tun->dev->name); switch (tun->flags & TUN_TYPE_MASK) { case TUN_TUN_DEV: @@ -161,7 +163,7 @@ static unsigned int tun_chr_poll(struct file *file, poll_table * wait) if (!tun) return -EBADFD; - DBG(KERN_INFO "%s: tun_chr_poll\n", tun->name); + DBG(KERN_INFO "%s: tun_chr_poll\n", tun->dev->name); poll_wait(file, &tun->read_wait, wait); @@ -226,7 +228,7 @@ static ssize_t tun_chr_writev(struct file * file, const struct iovec *iv, if (!tun) return -EBADFD; - DBG(KERN_INFO "%s: tun_chr_write %d\n", tun->name, count); + DBG(KERN_INFO "%s: tun_chr_write %ld\n", tun->dev->name, count); for (i = 0, len = 0; i < count; i++) { if (verify_area(VERIFY_READ, iv[i].iov_base, iv[i].iov_len)) @@ -290,7 +292,7 @@ static ssize_t tun_chr_readv(struct file *file, const struct iovec *iv, if (!tun) return -EBADFD; - DBG(KERN_INFO "%s: tun_chr_read\n", tun->name); + DBG(KERN_INFO "%s: tun_chr_read\n", tun->dev->name); for (i = 0, len = 0; i < count; i++) { if (verify_area(VERIFY_WRITE, iv[i].iov_base, iv[i].iov_len)) @@ -350,7 +352,7 @@ static void tun_setup(struct net_device *dev) tun->owner = -1; dev->init = tun_net_init; - tun->name = dev->name; + SET_MODULE_OWNER(dev); dev->open = tun_net_open; dev->hard_start_xmit = tun_net_xmit; @@ -359,27 +361,40 @@ static void tun_setup(struct net_device *dev) dev->destructor = (void (*)(struct net_device *))kfree; } +static struct tun_struct *tun_get_by_name(const char *name) +{ + struct tun_struct *tun; + + ASSERT_RTNL(); + list_for_each_entry(tun, &tun_dev_list, list) { + if (!strncmp(tun->dev->name, name, IFNAMSIZ)) + return tun; + } + + return NULL; +} + static int tun_set_iff(struct file *file, struct ifreq *ifr) { struct tun_struct *tun; - struct net_device *dev; int err; - dev = __dev_get_by_name(ifr->ifr_name); - if (dev) { - /* Device exist */ - tun = dev->priv; - - if (dev->init != tun_net_init || tun->attached) + tun = tun_get_by_name(ifr->ifr_name); + if (tun) { + if (tun->attached) return -EBUSY; /* Check permissions */ - if (tun->owner != -1) - if (current->euid != tun->owner && !capable(CAP_NET_ADMIN)) - return -EPERM; - } else { + if (tun->owner != -1 && + current->euid != tun->owner && !capable(CAP_NET_ADMIN)) + return -EPERM; + } + else if (__dev_get_by_name(ifr->ifr_name)) + return -EINVAL; + else { char *name; unsigned long flags = 0; + struct net_device *dev; err = -EINVAL; @@ -420,9 +435,10 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr) goto failed; } + list_add(&tun->list, &tun_dev_list); } - DBG(KERN_INFO "%s: tun_set_iff\n", tun->name); + DBG(KERN_INFO "%s: tun_set_iff\n", tun->dev->name); if (ifr->ifr_flags & IFF_NO_PI) tun->flags |= TUN_NO_PI; @@ -433,7 +449,7 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr) file->private_data = tun; tun->attached = 1; - strcpy(ifr->ifr_name, tun->name); + strcpy(ifr->ifr_name, tun->dev->name); return 0; failed: return err; @@ -466,7 +482,7 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file, if (!tun) return -EBADFD; - DBG(KERN_INFO "%s: tun_chr_ioctl cmd %d\n", tun->name, cmd); + DBG(KERN_INFO "%s: tun_chr_ioctl cmd %d\n", tun->dev->name, cmd); switch (cmd) { case TUNSETNOCSUM: @@ -477,7 +493,7 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file, tun->flags &= ~TUN_NOCHECKSUM; DBG(KERN_INFO "%s: checksum %s\n", - tun->name, arg ? "disabled" : "enabled"); + tun->dev->name, arg ? "disabled" : "enabled"); break; case TUNSETPERSIST: @@ -488,14 +504,14 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file, tun->flags &= ~TUN_PERSIST; DBG(KERN_INFO "%s: persist %s\n", - tun->name, arg ? "disabled" : "enabled"); + tun->dev->name, arg ? "disabled" : "enabled"); break; case TUNSETOWNER: /* Set owner of the device */ tun->owner = (uid_t) arg; - DBG(KERN_INFO "%s: owner set to %d\n", tun->owner); + DBG(KERN_INFO "%s: owner set to %d\n", tun->dev->name, tun->owner); break; #ifdef TUN_DEBUG @@ -519,7 +535,7 @@ static int tun_chr_fasync(int fd, struct file *file, int on) if (!tun) return -EBADFD; - DBG(KERN_INFO "%s: tun_chr_fasync %d\n", tun->name, on); + DBG(KERN_INFO "%s: tun_chr_fasync %d\n", tun->dev->name, on); if ((ret = fasync_helper(fd, file, on, &tun->fasync)) < 0) return ret; @@ -549,7 +565,7 @@ static int tun_chr_close(struct inode *inode, struct file *file) if (!tun) return 0; - DBG(KERN_INFO "%s: tun_chr_close\n", tun->name); + DBG(KERN_INFO "%s: tun_chr_close\n", tun->dev->name); tun_chr_fasync(-1, file, 0); @@ -562,8 +578,10 @@ static int tun_chr_close(struct inode *inode, struct file *file) /* Drop read queue */ skb_queue_purge(&tun->readq); - if (!(tun->flags & TUN_PERSIST)) + if (!(tun->flags & TUN_PERSIST)) { + list_del(&tun->list); unregister_netdevice(tun->dev); + } rtnl_unlock(); @@ -605,15 +623,14 @@ int __init tun_init(void) void tun_cleanup(void) { - struct net_device *dev, *nxt; + struct tun_struct *tun, *nxt; misc_deregister(&tun_miscdev); rtnl_lock(); - for (dev = dev_base; dev; dev = nxt) { - nxt = dev->next; - if (dev->init == tun_net_init) - unregister_netdevice(dev); + list_for_each_entry_safe(tun, nxt, &tun_dev_list, list) { + DBG(KERN_INFO "%s cleaned up\n", tun->dev->name); + unregister_netdevice(tun->dev); } rtnl_unlock(); diff --git a/include/linux/if_tun.h b/include/linux/if_tun.h index f8459e01c896..ad1e168004ee 100644 --- a/include/linux/if_tun.h +++ b/include/linux/if_tun.h @@ -32,7 +32,7 @@ #endif struct tun_struct { - char *name; + struct list_head list; unsigned long flags; int attached; uid_t owner; -- cgit v1.2.3