diff options
Diffstat (limited to 'net')
60 files changed, 1333 insertions, 971 deletions
diff --git a/net/atm/mpc.c b/net/atm/mpc.c index 17a81ebe7e6e..526d9531411f 100644 --- a/net/atm/mpc.c +++ b/net/atm/mpc.c | |||
| @@ -105,7 +105,7 @@ extern void mpc_proc_clean(void); | |||
| 105 | 105 | ||
| 106 | struct mpoa_client *mpcs = NULL; /* FIXME */ | 106 | struct mpoa_client *mpcs = NULL; /* FIXME */ |
| 107 | static struct atm_mpoa_qos *qos_head = NULL; | 107 | static struct atm_mpoa_qos *qos_head = NULL; |
| 108 | static struct timer_list mpc_timer = TIMER_INITIALIZER(NULL, 0, 0); | 108 | static DEFINE_TIMER(mpc_timer, NULL, 0, 0); |
| 109 | 109 | ||
| 110 | 110 | ||
| 111 | static struct mpoa_client *find_mpc_by_itfnum(int itf) | 111 | static struct mpoa_client *find_mpc_by_itfnum(int itf) |
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index ed705ddad56b..8e37e71e34ff 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c | |||
| @@ -1695,16 +1695,12 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
| 1695 | /* These two are safe on a single CPU system as only user tasks fiddle here */ | 1695 | /* These two are safe on a single CPU system as only user tasks fiddle here */ |
| 1696 | if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) | 1696 | if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) |
| 1697 | amount = skb->len; | 1697 | amount = skb->len; |
| 1698 | res = put_user(amount, (int __user *)argp); | 1698 | res = put_user(amount, (int __user *) argp); |
| 1699 | break; | 1699 | break; |
| 1700 | } | 1700 | } |
| 1701 | 1701 | ||
| 1702 | case SIOCGSTAMP: | 1702 | case SIOCGSTAMP: |
| 1703 | if (sk != NULL) { | 1703 | res = sock_get_timestamp(sk, argp); |
| 1704 | res = sock_get_timestamp(sk, argp); | ||
| 1705 | break; | ||
| 1706 | } | ||
| 1707 | res = -EINVAL; | ||
| 1708 | break; | 1704 | break; |
| 1709 | 1705 | ||
| 1710 | case SIOCAX25ADDUID: /* Add a uid to the uid/call map table */ | 1706 | case SIOCAX25ADDUID: /* Add a uid to the uid/call map table */ |
| @@ -1951,24 +1947,24 @@ static struct net_proto_family ax25_family_ops = { | |||
| 1951 | }; | 1947 | }; |
| 1952 | 1948 | ||
| 1953 | static struct proto_ops ax25_proto_ops = { | 1949 | static struct proto_ops ax25_proto_ops = { |
| 1954 | .family = PF_AX25, | 1950 | .family = PF_AX25, |
| 1955 | .owner = THIS_MODULE, | 1951 | .owner = THIS_MODULE, |
| 1956 | .release = ax25_release, | 1952 | .release = ax25_release, |
| 1957 | .bind = ax25_bind, | 1953 | .bind = ax25_bind, |
| 1958 | .connect = ax25_connect, | 1954 | .connect = ax25_connect, |
| 1959 | .socketpair = sock_no_socketpair, | 1955 | .socketpair = sock_no_socketpair, |
| 1960 | .accept = ax25_accept, | 1956 | .accept = ax25_accept, |
| 1961 | .getname = ax25_getname, | 1957 | .getname = ax25_getname, |
| 1962 | .poll = datagram_poll, | 1958 | .poll = datagram_poll, |
| 1963 | .ioctl = ax25_ioctl, | 1959 | .ioctl = ax25_ioctl, |
| 1964 | .listen = ax25_listen, | 1960 | .listen = ax25_listen, |
| 1965 | .shutdown = ax25_shutdown, | 1961 | .shutdown = ax25_shutdown, |
| 1966 | .setsockopt = ax25_setsockopt, | 1962 | .setsockopt = ax25_setsockopt, |
| 1967 | .getsockopt = ax25_getsockopt, | 1963 | .getsockopt = ax25_getsockopt, |
| 1968 | .sendmsg = ax25_sendmsg, | 1964 | .sendmsg = ax25_sendmsg, |
| 1969 | .recvmsg = ax25_recvmsg, | 1965 | .recvmsg = ax25_recvmsg, |
| 1970 | .mmap = sock_no_mmap, | 1966 | .mmap = sock_no_mmap, |
| 1971 | .sendpage = sock_no_sendpage, | 1967 | .sendpage = sock_no_sendpage, |
| 1972 | }; | 1968 | }; |
| 1973 | 1969 | ||
| 1974 | /* | 1970 | /* |
| @@ -1984,7 +1980,7 @@ static struct notifier_block ax25_dev_notifier = { | |||
| 1984 | .notifier_call =ax25_device_event, | 1980 | .notifier_call =ax25_device_event, |
| 1985 | }; | 1981 | }; |
| 1986 | 1982 | ||
| 1987 | EXPORT_SYMBOL(ax25_encapsulate); | 1983 | EXPORT_SYMBOL(ax25_hard_header); |
| 1988 | EXPORT_SYMBOL(ax25_rebuild_header); | 1984 | EXPORT_SYMBOL(ax25_rebuild_header); |
| 1989 | EXPORT_SYMBOL(ax25_findbyuid); | 1985 | EXPORT_SYMBOL(ax25_findbyuid); |
| 1990 | EXPORT_SYMBOL(ax25_find_cb); | 1986 | EXPORT_SYMBOL(ax25_find_cb); |
diff --git a/net/ax25/ax25_addr.c b/net/ax25/ax25_addr.c index dca179daf415..0164a155b8c4 100644 --- a/net/ax25/ax25_addr.c +++ b/net/ax25/ax25_addr.c | |||
| @@ -67,37 +67,34 @@ char *ax2asc(char *buf, ax25_address *a) | |||
| 67 | /* | 67 | /* |
| 68 | * ascii -> ax25 conversion | 68 | * ascii -> ax25 conversion |
| 69 | */ | 69 | */ |
| 70 | ax25_address *asc2ax(char *callsign) | 70 | void asc2ax(ax25_address *addr, char *callsign) |
| 71 | { | 71 | { |
| 72 | static ax25_address addr; | ||
| 73 | char *s; | 72 | char *s; |
| 74 | int n; | 73 | int n; |
| 75 | 74 | ||
| 76 | for (s = callsign, n = 0; n < 6; n++) { | 75 | for (s = callsign, n = 0; n < 6; n++) { |
| 77 | if (*s != '\0' && *s != '-') | 76 | if (*s != '\0' && *s != '-') |
| 78 | addr.ax25_call[n] = *s++; | 77 | addr->ax25_call[n] = *s++; |
| 79 | else | 78 | else |
| 80 | addr.ax25_call[n] = ' '; | 79 | addr->ax25_call[n] = ' '; |
| 81 | addr.ax25_call[n] <<= 1; | 80 | addr->ax25_call[n] <<= 1; |
| 82 | addr.ax25_call[n] &= 0xFE; | 81 | addr->ax25_call[n] &= 0xFE; |
| 83 | } | 82 | } |
| 84 | 83 | ||
| 85 | if (*s++ == '\0') { | 84 | if (*s++ == '\0') { |
| 86 | addr.ax25_call[6] = 0x00; | 85 | addr->ax25_call[6] = 0x00; |
| 87 | return &addr; | 86 | return; |
| 88 | } | 87 | } |
| 89 | 88 | ||
| 90 | addr.ax25_call[6] = *s++ - '0'; | 89 | addr->ax25_call[6] = *s++ - '0'; |
| 91 | 90 | ||
| 92 | if (*s != '\0') { | 91 | if (*s != '\0') { |
| 93 | addr.ax25_call[6] *= 10; | 92 | addr->ax25_call[6] *= 10; |
| 94 | addr.ax25_call[6] += *s++ - '0'; | 93 | addr->ax25_call[6] += *s++ - '0'; |
| 95 | } | 94 | } |
| 96 | 95 | ||
| 97 | addr.ax25_call[6] <<= 1; | 96 | addr->ax25_call[6] <<= 1; |
| 98 | addr.ax25_call[6] &= 0x1E; | 97 | addr->ax25_call[6] &= 0x1E; |
| 99 | |||
| 100 | return &addr; | ||
| 101 | } | 98 | } |
| 102 | 99 | ||
| 103 | /* | 100 | /* |
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 @@ | |||
| 47 | 47 | ||
| 48 | #ifdef CONFIG_INET | 48 | #ifdef CONFIG_INET |
| 49 | 49 | ||
| 50 | int ax25_encapsulate(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len) | 50 | int ax25_hard_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len) |
| 51 | { | 51 | { |
| 52 | unsigned char *buff; | 52 | unsigned char *buff; |
| 53 | 53 | ||
| @@ -88,7 +88,7 @@ int ax25_encapsulate(struct sk_buff *skb, struct net_device *dev, unsigned short | |||
| 88 | *buff++ = AX25_P_ARP; | 88 | *buff++ = AX25_P_ARP; |
| 89 | break; | 89 | break; |
| 90 | default: | 90 | default: |
| 91 | printk(KERN_ERR "AX.25: ax25_encapsulate - wrong protocol type 0x%2.2x\n", type); | 91 | printk(KERN_ERR "AX.25: ax25_hard_header - wrong protocol type 0x%2.2x\n", type); |
| 92 | *buff++ = 0; | 92 | *buff++ = 0; |
| 93 | break; | 93 | break; |
| 94 | } | 94 | } |
| @@ -209,7 +209,7 @@ put: | |||
| 209 | 209 | ||
| 210 | #else /* INET */ | 210 | #else /* INET */ |
| 211 | 211 | ||
| 212 | int ax25_encapsulate(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len) | 212 | int ax25_hard_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len) |
| 213 | { | 213 | { |
| 214 | return -AX25_HEADER_LEN; | 214 | return -AX25_HEADER_LEN; |
| 215 | } | 215 | } |
diff --git a/net/compat.c b/net/compat.c index d99ab9695893..e593dace2fdb 100644 --- a/net/compat.c +++ b/net/compat.c | |||
| @@ -135,13 +135,14 @@ static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *ms | |||
| 135 | * thus placement) of cmsg headers and length are different for | 135 | * thus placement) of cmsg headers and length are different for |
| 136 | * 32-bit apps. -DaveM | 136 | * 32-bit apps. -DaveM |
| 137 | */ | 137 | */ |
| 138 | int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, | 138 | int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk, |
| 139 | unsigned char *stackbuf, int stackbuf_size) | 139 | unsigned char *stackbuf, int stackbuf_size) |
| 140 | { | 140 | { |
| 141 | struct compat_cmsghdr __user *ucmsg; | 141 | struct compat_cmsghdr __user *ucmsg; |
| 142 | struct cmsghdr *kcmsg, *kcmsg_base; | 142 | struct cmsghdr *kcmsg, *kcmsg_base; |
| 143 | compat_size_t ucmlen; | 143 | compat_size_t ucmlen; |
| 144 | __kernel_size_t kcmlen, tmp; | 144 | __kernel_size_t kcmlen, tmp; |
| 145 | int err = -EFAULT; | ||
| 145 | 146 | ||
| 146 | kcmlen = 0; | 147 | kcmlen = 0; |
| 147 | kcmsg_base = kcmsg = (struct cmsghdr *)stackbuf; | 148 | kcmsg_base = kcmsg = (struct cmsghdr *)stackbuf; |
| @@ -156,6 +157,7 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, | |||
| 156 | 157 | ||
| 157 | tmp = ((ucmlen - CMSG_COMPAT_ALIGN(sizeof(*ucmsg))) + | 158 | tmp = ((ucmlen - CMSG_COMPAT_ALIGN(sizeof(*ucmsg))) + |
| 158 | CMSG_ALIGN(sizeof(struct cmsghdr))); | 159 | CMSG_ALIGN(sizeof(struct cmsghdr))); |
| 160 | tmp = CMSG_ALIGN(tmp); | ||
| 159 | kcmlen += tmp; | 161 | kcmlen += tmp; |
| 160 | ucmsg = cmsg_compat_nxthdr(kmsg, ucmsg, ucmlen); | 162 | ucmsg = cmsg_compat_nxthdr(kmsg, ucmsg, ucmlen); |
| 161 | } | 163 | } |
| @@ -167,30 +169,34 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, | |||
| 167 | * until we have successfully copied over all of the data | 169 | * until we have successfully copied over all of the data |
| 168 | * from the user. | 170 | * from the user. |
| 169 | */ | 171 | */ |
| 170 | if(kcmlen > stackbuf_size) | 172 | if (kcmlen > stackbuf_size) |
| 171 | kcmsg_base = kcmsg = kmalloc(kcmlen, GFP_KERNEL); | 173 | kcmsg_base = kcmsg = sock_kmalloc(sk, kcmlen, GFP_KERNEL); |
| 172 | if(kcmsg == NULL) | 174 | if (kcmsg == NULL) |
| 173 | return -ENOBUFS; | 175 | return -ENOBUFS; |
| 174 | 176 | ||
| 175 | /* Now copy them over neatly. */ | 177 | /* Now copy them over neatly. */ |
| 176 | memset(kcmsg, 0, kcmlen); | 178 | memset(kcmsg, 0, kcmlen); |
| 177 | ucmsg = CMSG_COMPAT_FIRSTHDR(kmsg); | 179 | ucmsg = CMSG_COMPAT_FIRSTHDR(kmsg); |
| 178 | while(ucmsg != NULL) { | 180 | while(ucmsg != NULL) { |
| 179 | __get_user(ucmlen, &ucmsg->cmsg_len); | 181 | if (__get_user(ucmlen, &ucmsg->cmsg_len)) |
| 182 | goto Efault; | ||
| 183 | if (!CMSG_COMPAT_OK(ucmlen, ucmsg, kmsg)) | ||
| 184 | goto Einval; | ||
| 180 | tmp = ((ucmlen - CMSG_COMPAT_ALIGN(sizeof(*ucmsg))) + | 185 | tmp = ((ucmlen - CMSG_COMPAT_ALIGN(sizeof(*ucmsg))) + |
| 181 | CMSG_ALIGN(sizeof(struct cmsghdr))); | 186 | CMSG_ALIGN(sizeof(struct cmsghdr))); |
| 187 | if ((char *)kcmsg_base + kcmlen - (char *)kcmsg < CMSG_ALIGN(tmp)) | ||
| 188 | goto Einval; | ||
| 182 | kcmsg->cmsg_len = tmp; | 189 | kcmsg->cmsg_len = tmp; |
| 183 | __get_user(kcmsg->cmsg_level, &ucmsg->cmsg_level); | 190 | tmp = CMSG_ALIGN(tmp); |
| 184 | __get_user(kcmsg->cmsg_type, &ucmsg->cmsg_type); | 191 | if (__get_user(kcmsg->cmsg_level, &ucmsg->cmsg_level) || |
| 185 | 192 | __get_user(kcmsg->cmsg_type, &ucmsg->cmsg_type) || | |
| 186 | /* Copy over the data. */ | 193 | copy_from_user(CMSG_DATA(kcmsg), |
| 187 | if(copy_from_user(CMSG_DATA(kcmsg), | 194 | CMSG_COMPAT_DATA(ucmsg), |
| 188 | CMSG_COMPAT_DATA(ucmsg), | 195 | (ucmlen - CMSG_COMPAT_ALIGN(sizeof(*ucmsg))))) |
| 189 | (ucmlen - CMSG_COMPAT_ALIGN(sizeof(*ucmsg))))) | 196 | goto Efault; |
| 190 | goto out_free_efault; | ||
| 191 | 197 | ||
| 192 | /* Advance. */ | 198 | /* Advance. */ |
| 193 | kcmsg = (struct cmsghdr *)((char *)kcmsg + CMSG_ALIGN(tmp)); | 199 | kcmsg = (struct cmsghdr *)((char *)kcmsg + tmp); |
| 194 | ucmsg = cmsg_compat_nxthdr(kmsg, ucmsg, ucmlen); | 200 | ucmsg = cmsg_compat_nxthdr(kmsg, ucmsg, ucmlen); |
| 195 | } | 201 | } |
| 196 | 202 | ||
| @@ -199,10 +205,12 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, | |||
| 199 | kmsg->msg_controllen = kcmlen; | 205 | kmsg->msg_controllen = kcmlen; |
| 200 | return 0; | 206 | return 0; |
| 201 | 207 | ||
| 202 | out_free_efault: | 208 | Einval: |
| 203 | if(kcmsg_base != (struct cmsghdr *)stackbuf) | 209 | err = -EINVAL; |
| 204 | kfree(kcmsg_base); | 210 | Efault: |
| 205 | return -EFAULT; | 211 | if (kcmsg_base != (struct cmsghdr *)stackbuf) |
| 212 | sock_kfree_s(sk, kcmsg_base, kcmlen); | ||
| 213 | return err; | ||
| 206 | } | 214 | } |
| 207 | 215 | ||
| 208 | int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data) | 216 | int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data) |
diff --git a/net/core/dst.c b/net/core/dst.c index 334790da9f16..470c05bc4cb2 100644 --- a/net/core/dst.c +++ b/net/core/dst.c | |||
| @@ -39,8 +39,7 @@ static unsigned long dst_gc_timer_inc = DST_GC_MAX; | |||
| 39 | static void dst_run_gc(unsigned long); | 39 | static void dst_run_gc(unsigned long); |
| 40 | static void ___dst_free(struct dst_entry * dst); | 40 | static void ___dst_free(struct dst_entry * dst); |
| 41 | 41 | ||
| 42 | static struct timer_list dst_gc_timer = | 42 | static DEFINE_TIMER(dst_gc_timer, dst_run_gc, DST_GC_MIN, 0); |
| 43 | TIMER_INITIALIZER(dst_run_gc, DST_GC_MIN, 0); | ||
| 44 | 43 | ||
| 45 | static void dst_run_gc(unsigned long dummy) | 44 | static void dst_run_gc(unsigned long dummy) |
| 46 | { | 45 | { |
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index a1a9a7abff50..5265dfd69928 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
| @@ -645,10 +645,10 @@ int netpoll_setup(struct netpoll *np) | |||
| 645 | 645 | ||
| 646 | npinfo->rx_flags = 0; | 646 | npinfo->rx_flags = 0; |
| 647 | npinfo->rx_np = NULL; | 647 | npinfo->rx_np = NULL; |
| 648 | npinfo->poll_lock = SPIN_LOCK_UNLOCKED; | 648 | spin_lock_init(&npinfo->poll_lock); |
| 649 | npinfo->poll_owner = -1; | 649 | npinfo->poll_owner = -1; |
| 650 | npinfo->tries = MAX_RETRIES; | 650 | npinfo->tries = MAX_RETRIES; |
| 651 | npinfo->rx_lock = SPIN_LOCK_UNLOCKED; | 651 | spin_lock_init(&npinfo->rx_lock); |
| 652 | } else | 652 | } else |
| 653 | npinfo = ndev->npinfo; | 653 | npinfo = ndev->npinfo; |
| 654 | 654 | ||
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 8eb083b6041a..ef430b1e8e42 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
| @@ -503,7 +503,7 @@ static int pg_delay_d = 0; | |||
| 503 | static int pg_clone_skb_d = 0; | 503 | static int pg_clone_skb_d = 0; |
| 504 | static int debug = 0; | 504 | static int debug = 0; |
| 505 | 505 | ||
| 506 | static spinlock_t _thread_lock = SPIN_LOCK_UNLOCKED; | 506 | static DEFINE_SPINLOCK(_thread_lock); |
| 507 | static struct pktgen_thread *pktgen_threads = NULL; | 507 | static struct pktgen_thread *pktgen_threads = NULL; |
| 508 | 508 | ||
| 509 | static char module_fname[128]; | 509 | static char module_fname[128]; |
| @@ -1452,8 +1452,7 @@ static int proc_thread_write(struct file *file, const char __user *user_buffer, | |||
| 1452 | thread_lock(); | 1452 | thread_lock(); |
| 1453 | t->control |= T_REMDEV; | 1453 | t->control |= T_REMDEV; |
| 1454 | thread_unlock(); | 1454 | thread_unlock(); |
| 1455 | current->state = TASK_INTERRUPTIBLE; | 1455 | schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */ |
| 1456 | schedule_timeout(HZ/8); /* Propagate thread->control */ | ||
| 1457 | ret = count; | 1456 | ret = count; |
| 1458 | sprintf(pg_result, "OK: rem_device_all"); | 1457 | sprintf(pg_result, "OK: rem_device_all"); |
| 1459 | goto out; | 1458 | goto out; |
| @@ -1716,10 +1715,9 @@ static void spin(struct pktgen_dev *pkt_dev, __u64 spin_until_us) | |||
| 1716 | printk(KERN_INFO "sleeping for %d\n", (int)(spin_until_us - now)); | 1715 | printk(KERN_INFO "sleeping for %d\n", (int)(spin_until_us - now)); |
| 1717 | while (now < spin_until_us) { | 1716 | while (now < spin_until_us) { |
| 1718 | /* TODO: optimise sleeping behavior */ | 1717 | /* TODO: optimise sleeping behavior */ |
| 1719 | if (spin_until_us - now > (1000000/HZ)+1) { | 1718 | if (spin_until_us - now > jiffies_to_usecs(1)+1) |
| 1720 | current->state = TASK_INTERRUPTIBLE; | 1719 | schedule_timeout_interruptible(1); |
| 1721 | schedule_timeout(1); | 1720 | else if (spin_until_us - now > 100) { |
| 1722 | } else if (spin_until_us - now > 100) { | ||
| 1723 | do_softirq(); | 1721 | do_softirq(); |
| 1724 | if (!pkt_dev->running) | 1722 | if (!pkt_dev->running) |
| 1725 | return; | 1723 | return; |
| @@ -2449,8 +2447,7 @@ static void pktgen_run_all_threads(void) | |||
| 2449 | } | 2447 | } |
| 2450 | thread_unlock(); | 2448 | thread_unlock(); |
| 2451 | 2449 | ||
| 2452 | current->state = TASK_INTERRUPTIBLE; | 2450 | schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */ |
| 2453 | schedule_timeout(HZ/8); /* Propagate thread->control */ | ||
| 2454 | 2451 | ||
| 2455 | pktgen_wait_all_threads_run(); | 2452 | pktgen_wait_all_threads_run(); |
| 2456 | } | 2453 | } |
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 7bf3b3a91e97..38aa84986118 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
| @@ -43,12 +43,22 @@ | |||
| 43 | #include "ccid3.h" | 43 | #include "ccid3.h" |
| 44 | 44 | ||
| 45 | /* | 45 | /* |
| 46 | * Reason for maths with 10 here is to avoid 32 bit overflow when a is big. | 46 | * Reason for maths here is to avoid 32 bit overflow when a is big. |
| 47 | * With this we get close to the limit. | ||
| 47 | */ | 48 | */ |
| 48 | static inline u32 usecs_div(const u32 a, const u32 b) | 49 | static inline u32 usecs_div(const u32 a, const u32 b) |
| 49 | { | 50 | { |
| 50 | const u32 tmp = a * (USEC_PER_SEC / 10); | 51 | const u32 div = a < (UINT_MAX / (USEC_PER_SEC / 10)) ? 10 : |
| 51 | return b > 20 ? tmp / (b / 10) : tmp; | 52 | a < (UINT_MAX / (USEC_PER_SEC / 50)) ? 50 : |
| 53 | a < (UINT_MAX / (USEC_PER_SEC / 100)) ? 100 : | ||
| 54 | a < (UINT_MAX / (USEC_PER_SEC / 500)) ? 500 : | ||
| 55 | a < (UINT_MAX / (USEC_PER_SEC / 1000)) ? 1000 : | ||
| 56 | a < (UINT_MAX / (USEC_PER_SEC / 5000)) ? 5000 : | ||
| 57 | a < (UINT_MAX / (USEC_PER_SEC / 10000)) ? 10000 : | ||
| 58 | a < (UINT_MAX / (USEC_PER_SEC / 50000)) ? 50000 : | ||
| 59 | 100000; | ||
| 60 | const u32 tmp = a * (USEC_PER_SEC / div); | ||
| 61 | return (b >= 2 * div) ? tmp / (b / div) : tmp; | ||
| 52 | } | 62 | } |
| 53 | 63 | ||
| 54 | static int ccid3_debug; | 64 | static int ccid3_debug; |
| @@ -68,13 +78,11 @@ static struct dccp_li_hist *ccid3_li_hist; | |||
| 68 | 78 | ||
| 69 | static int ccid3_init(struct sock *sk) | 79 | static int ccid3_init(struct sock *sk) |
| 70 | { | 80 | { |
| 71 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | ||
| 72 | return 0; | 81 | return 0; |
| 73 | } | 82 | } |
| 74 | 83 | ||
| 75 | static void ccid3_exit(struct sock *sk) | 84 | static void ccid3_exit(struct sock *sk) |
| 76 | { | 85 | { |
| 77 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | ||
| 78 | } | 86 | } |
| 79 | 87 | ||
| 80 | /* TFRC sender states */ | 88 | /* TFRC sender states */ |
| @@ -102,8 +110,7 @@ static const char *ccid3_tx_state_name(enum ccid3_hc_tx_states state) | |||
| 102 | static inline void ccid3_hc_tx_set_state(struct sock *sk, | 110 | static inline void ccid3_hc_tx_set_state(struct sock *sk, |
| 103 | enum ccid3_hc_tx_states state) | 111 | enum ccid3_hc_tx_states state) |
| 104 | { | 112 | { |
| 105 | struct dccp_sock *dp = dccp_sk(sk); | 113 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
| 106 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | ||
| 107 | enum ccid3_hc_tx_states oldstate = hctx->ccid3hctx_state; | 114 | enum ccid3_hc_tx_states oldstate = hctx->ccid3hctx_state; |
| 108 | 115 | ||
| 109 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", | 116 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", |
| @@ -144,8 +151,7 @@ static inline void ccid3_calc_new_delta(struct ccid3_hc_tx_sock *hctx) | |||
| 144 | */ | 151 | */ |
| 145 | static void ccid3_hc_tx_update_x(struct sock *sk) | 152 | static void ccid3_hc_tx_update_x(struct sock *sk) |
| 146 | { | 153 | { |
| 147 | struct dccp_sock *dp = dccp_sk(sk); | 154 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
| 148 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | ||
| 149 | 155 | ||
| 150 | /* To avoid large error in calcX */ | 156 | /* To avoid large error in calcX */ |
| 151 | if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) { | 157 | if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) { |
| @@ -159,7 +165,7 @@ static void ccid3_hc_tx_update_x(struct sock *sk) | |||
| 159 | } else { | 165 | } else { |
| 160 | struct timeval now; | 166 | struct timeval now; |
| 161 | 167 | ||
| 162 | do_gettimeofday(&now); | 168 | dccp_timestamp(sk, &now); |
| 163 | if (timeval_delta(&now, &hctx->ccid3hctx_t_ld) >= | 169 | if (timeval_delta(&now, &hctx->ccid3hctx_t_ld) >= |
| 164 | hctx->ccid3hctx_rtt) { | 170 | hctx->ccid3hctx_rtt) { |
| 165 | hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_recv, | 171 | hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_recv, |
| @@ -174,9 +180,8 @@ static void ccid3_hc_tx_update_x(struct sock *sk) | |||
| 174 | static void ccid3_hc_tx_no_feedback_timer(unsigned long data) | 180 | static void ccid3_hc_tx_no_feedback_timer(unsigned long data) |
| 175 | { | 181 | { |
| 176 | struct sock *sk = (struct sock *)data; | 182 | struct sock *sk = (struct sock *)data; |
| 177 | struct dccp_sock *dp = dccp_sk(sk); | ||
| 178 | unsigned long next_tmout = 0; | 183 | unsigned long next_tmout = 0; |
| 179 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 184 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
| 180 | 185 | ||
| 181 | bh_lock_sock(sk); | 186 | bh_lock_sock(sk); |
| 182 | if (sock_owned_by_user(sk)) { | 187 | if (sock_owned_by_user(sk)) { |
| @@ -274,20 +279,20 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
| 274 | struct sk_buff *skb, int len) | 279 | struct sk_buff *skb, int len) |
| 275 | { | 280 | { |
| 276 | struct dccp_sock *dp = dccp_sk(sk); | 281 | struct dccp_sock *dp = dccp_sk(sk); |
| 277 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 282 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
| 278 | struct dccp_tx_hist_entry *new_packet; | 283 | struct dccp_tx_hist_entry *new_packet; |
| 279 | struct timeval now; | 284 | struct timeval now; |
| 280 | long delay; | 285 | long delay; |
| 281 | int rc = -ENOTCONN; | 286 | int rc = -ENOTCONN; |
| 282 | 287 | ||
| 283 | /* Check if pure ACK or Terminating*/ | 288 | BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM); |
| 284 | 289 | ||
| 290 | /* Check if pure ACK or Terminating*/ | ||
| 285 | /* | 291 | /* |
| 286 | * XXX: We only call this function for DATA and DATAACK, on, these | 292 | * XXX: We only call this function for DATA and DATAACK, on, these |
| 287 | * packets can have zero length, but why the comment about "pure ACK"? | 293 | * packets can have zero length, but why the comment about "pure ACK"? |
| 288 | */ | 294 | */ |
| 289 | if (hctx == NULL || len == 0 || | 295 | if (unlikely(len == 0)) |
| 290 | hctx->ccid3hctx_state == TFRC_SSTATE_TERM) | ||
| 291 | goto out; | 296 | goto out; |
| 292 | 297 | ||
| 293 | /* See if last packet allocated was not sent */ | 298 | /* See if last packet allocated was not sent */ |
| @@ -297,23 +302,20 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
| 297 | SLAB_ATOMIC); | 302 | SLAB_ATOMIC); |
| 298 | 303 | ||
| 299 | rc = -ENOBUFS; | 304 | rc = -ENOBUFS; |
| 300 | if (new_packet == NULL) { | 305 | if (unlikely(new_packet == NULL)) { |
| 301 | ccid3_pr_debug("%s, sk=%p, not enough mem to add " | 306 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, not enough " |
| 302 | "to history, send refused\n", | 307 | "mem to add to history, send refused\n", |
| 303 | dccp_role(sk), sk); | 308 | __FUNCTION__, dccp_role(sk), sk); |
| 304 | goto out; | 309 | goto out; |
| 305 | } | 310 | } |
| 306 | 311 | ||
| 307 | dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet); | 312 | dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet); |
| 308 | } | 313 | } |
| 309 | 314 | ||
| 310 | do_gettimeofday(&now); | 315 | dccp_timestamp(sk, &now); |
| 311 | 316 | ||
| 312 | switch (hctx->ccid3hctx_state) { | 317 | switch (hctx->ccid3hctx_state) { |
| 313 | case TFRC_SSTATE_NO_SENT: | 318 | case TFRC_SSTATE_NO_SENT: |
| 314 | ccid3_pr_debug("%s, sk=%p, first packet(%llu)\n", | ||
| 315 | dccp_role(sk), sk, dp->dccps_gss); | ||
| 316 | |||
| 317 | hctx->ccid3hctx_no_feedback_timer.function = ccid3_hc_tx_no_feedback_timer; | 319 | hctx->ccid3hctx_no_feedback_timer.function = ccid3_hc_tx_no_feedback_timer; |
| 318 | hctx->ccid3hctx_no_feedback_timer.data = (unsigned long)sk; | 320 | hctx->ccid3hctx_no_feedback_timer.data = (unsigned long)sk; |
| 319 | sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, | 321 | sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, |
| @@ -321,7 +323,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
| 321 | hctx->ccid3hctx_last_win_count = 0; | 323 | hctx->ccid3hctx_last_win_count = 0; |
| 322 | hctx->ccid3hctx_t_last_win_count = now; | 324 | hctx->ccid3hctx_t_last_win_count = now; |
| 323 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK); | 325 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK); |
| 324 | hctx->ccid3hctx_t_ipi = TFRC_INITIAL_TIMEOUT; | 326 | hctx->ccid3hctx_t_ipi = TFRC_INITIAL_IPI; |
| 325 | 327 | ||
| 326 | /* Set nominal send time for initial packet */ | 328 | /* Set nominal send time for initial packet */ |
| 327 | hctx->ccid3hctx_t_nom = now; | 329 | hctx->ccid3hctx_t_nom = now; |
| @@ -334,7 +336,6 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
| 334 | case TFRC_SSTATE_FBACK: | 336 | case TFRC_SSTATE_FBACK: |
| 335 | delay = (timeval_delta(&now, &hctx->ccid3hctx_t_nom) - | 337 | delay = (timeval_delta(&now, &hctx->ccid3hctx_t_nom) - |
| 336 | hctx->ccid3hctx_delta); | 338 | hctx->ccid3hctx_delta); |
| 337 | ccid3_pr_debug("send_packet delay=%ld\n", delay); | ||
| 338 | delay /= -1000; | 339 | delay /= -1000; |
| 339 | /* divide by -1000 is to convert to ms and get sign right */ | 340 | /* divide by -1000 is to convert to ms and get sign right */ |
| 340 | rc = delay > 0 ? delay : 0; | 341 | rc = delay > 0 ? delay : 0; |
| @@ -348,29 +349,25 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
| 348 | } | 349 | } |
| 349 | 350 | ||
| 350 | /* Can we send? if so add options and add to packet history */ | 351 | /* Can we send? if so add options and add to packet history */ |
| 351 | if (rc == 0) | 352 | if (rc == 0) { |
| 353 | dp->dccps_hc_tx_insert_options = 1; | ||
| 352 | new_packet->dccphtx_ccval = | 354 | new_packet->dccphtx_ccval = |
| 353 | DCCP_SKB_CB(skb)->dccpd_ccval = | 355 | DCCP_SKB_CB(skb)->dccpd_ccval = |
| 354 | hctx->ccid3hctx_last_win_count; | 356 | hctx->ccid3hctx_last_win_count; |
| 357 | } | ||
| 355 | out: | 358 | out: |
| 356 | return rc; | 359 | return rc; |
| 357 | } | 360 | } |
| 358 | 361 | ||
| 359 | static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) | 362 | static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) |
| 360 | { | 363 | { |
| 361 | struct dccp_sock *dp = dccp_sk(sk); | 364 | const struct dccp_sock *dp = dccp_sk(sk); |
| 362 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 365 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
| 363 | struct timeval now; | 366 | struct timeval now; |
| 364 | 367 | ||
| 365 | BUG_ON(hctx == NULL); | 368 | BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM); |
| 366 | |||
| 367 | if (hctx->ccid3hctx_state == TFRC_SSTATE_TERM) { | ||
| 368 | ccid3_pr_debug("%s, sk=%p, while state is TFRC_SSTATE_TERM!\n", | ||
| 369 | dccp_role(sk), sk); | ||
| 370 | return; | ||
| 371 | } | ||
| 372 | 369 | ||
| 373 | do_gettimeofday(&now); | 370 | dccp_timestamp(sk, &now); |
| 374 | 371 | ||
| 375 | /* check if we have sent a data packet */ | 372 | /* check if we have sent a data packet */ |
| 376 | if (len > 0) { | 373 | if (len > 0) { |
| @@ -378,14 +375,14 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) | |||
| 378 | struct dccp_tx_hist_entry *packet; | 375 | struct dccp_tx_hist_entry *packet; |
| 379 | 376 | ||
| 380 | packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist); | 377 | packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist); |
| 381 | if (packet == NULL) { | 378 | if (unlikely(packet == NULL)) { |
| 382 | printk(KERN_CRIT "%s: packet doesn't exists in " | 379 | LIMIT_NETDEBUG(KERN_WARNING "%s: packet doesn't " |
| 383 | "history!\n", __FUNCTION__); | 380 | "exists in history!\n", __FUNCTION__); |
| 384 | return; | 381 | return; |
| 385 | } | 382 | } |
| 386 | if (packet->dccphtx_sent) { | 383 | if (unlikely(packet->dccphtx_sent)) { |
| 387 | printk(KERN_CRIT "%s: no unsent packet in history!\n", | 384 | LIMIT_NETDEBUG(KERN_WARNING "%s: no unsent packet in " |
| 388 | __FUNCTION__); | 385 | "history!\n", __FUNCTION__); |
| 389 | return; | 386 | return; |
| 390 | } | 387 | } |
| 391 | packet->dccphtx_tstamp = now; | 388 | packet->dccphtx_tstamp = now; |
| @@ -445,24 +442,18 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) | |||
| 445 | 442 | ||
| 446 | static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | 443 | static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) |
| 447 | { | 444 | { |
| 448 | struct dccp_sock *dp = dccp_sk(sk); | 445 | const struct dccp_sock *dp = dccp_sk(sk); |
| 449 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 446 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
| 450 | struct ccid3_options_received *opt_recv; | 447 | struct ccid3_options_received *opt_recv; |
| 451 | struct dccp_tx_hist_entry *packet; | 448 | struct dccp_tx_hist_entry *packet; |
| 449 | struct timeval now; | ||
| 452 | unsigned long next_tmout; | 450 | unsigned long next_tmout; |
| 453 | u32 t_elapsed; | 451 | u32 t_elapsed; |
| 454 | u32 pinv; | 452 | u32 pinv; |
| 455 | u32 x_recv; | 453 | u32 x_recv; |
| 456 | u32 r_sample; | 454 | u32 r_sample; |
| 457 | 455 | ||
| 458 | if (hctx == NULL) | 456 | BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM); |
| 459 | return; | ||
| 460 | |||
| 461 | if (hctx->ccid3hctx_state == TFRC_SSTATE_TERM) { | ||
| 462 | ccid3_pr_debug("%s, sk=%p, received a packet when " | ||
| 463 | "terminating!\n", dccp_role(sk), sk); | ||
| 464 | return; | ||
| 465 | } | ||
| 466 | 457 | ||
| 467 | /* we are only interested in ACKs */ | 458 | /* we are only interested in ACKs */ |
| 468 | if (!(DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK || | 459 | if (!(DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK || |
| @@ -471,7 +462,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
| 471 | 462 | ||
| 472 | opt_recv = &hctx->ccid3hctx_options_received; | 463 | opt_recv = &hctx->ccid3hctx_options_received; |
| 473 | 464 | ||
| 474 | t_elapsed = dp->dccps_options_received.dccpor_elapsed_time; | 465 | t_elapsed = dp->dccps_options_received.dccpor_elapsed_time * 10; |
| 475 | x_recv = opt_recv->ccid3or_receive_rate; | 466 | x_recv = opt_recv->ccid3or_receive_rate; |
| 476 | pinv = opt_recv->ccid3or_loss_event_rate; | 467 | pinv = opt_recv->ccid3or_loss_event_rate; |
| 477 | 468 | ||
| @@ -486,19 +477,24 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
| 486 | /* get t_recvdata from history */ | 477 | /* get t_recvdata from history */ |
| 487 | packet = dccp_tx_hist_find_entry(&hctx->ccid3hctx_hist, | 478 | packet = dccp_tx_hist_find_entry(&hctx->ccid3hctx_hist, |
| 488 | DCCP_SKB_CB(skb)->dccpd_ack_seq); | 479 | DCCP_SKB_CB(skb)->dccpd_ack_seq); |
| 489 | if (packet == NULL) { | 480 | if (unlikely(packet == NULL)) { |
| 490 | ccid3_pr_debug("%s, sk=%p, seqno %llu(%s) does't " | 481 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, seqno " |
| 491 | "exist in history!\n", | 482 | "%llu(%s) does't exist in history!\n", |
| 492 | dccp_role(sk), sk, | 483 | __FUNCTION__, dccp_role(sk), sk, |
| 493 | DCCP_SKB_CB(skb)->dccpd_ack_seq, | 484 | (unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq, |
| 494 | dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type)); | 485 | dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type)); |
| 495 | return; | 486 | return; |
| 496 | } | 487 | } |
| 497 | 488 | ||
| 498 | /* Update RTT */ | 489 | /* Update RTT */ |
| 499 | r_sample = timeval_now_delta(&packet->dccphtx_tstamp); | 490 | dccp_timestamp(sk, &now); |
| 500 | /* FIXME: */ | 491 | r_sample = timeval_delta(&now, &packet->dccphtx_tstamp); |
| 501 | // r_sample -= usecs_to_jiffies(t_elapsed * 10); | 492 | if (unlikely(r_sample <= t_elapsed)) |
| 493 | LIMIT_NETDEBUG(KERN_WARNING "%s: r_sample=%uus, " | ||
| 494 | "t_elapsed=%uus\n", | ||
| 495 | __FUNCTION__, r_sample, t_elapsed); | ||
| 496 | else | ||
| 497 | r_sample -= t_elapsed; | ||
| 502 | 498 | ||
| 503 | /* Update RTT estimate by | 499 | /* Update RTT estimate by |
| 504 | * If (No feedback recv) | 500 | * If (No feedback recv) |
| @@ -591,11 +587,11 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
| 591 | 587 | ||
| 592 | static void ccid3_hc_tx_insert_options(struct sock *sk, struct sk_buff *skb) | 588 | static void ccid3_hc_tx_insert_options(struct sock *sk, struct sk_buff *skb) |
| 593 | { | 589 | { |
| 594 | const struct dccp_sock *dp = dccp_sk(sk); | 590 | const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
| 595 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 591 | |
| 592 | BUG_ON(hctx == NULL); | ||
| 596 | 593 | ||
| 597 | if (hctx == NULL || !(sk->sk_state == DCCP_OPEN || | 594 | if (!(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)) |
| 598 | sk->sk_state == DCCP_PARTOPEN)) | ||
| 599 | return; | 595 | return; |
| 600 | 596 | ||
| 601 | DCCP_SKB_CB(skb)->dccpd_ccval = hctx->ccid3hctx_last_win_count; | 597 | DCCP_SKB_CB(skb)->dccpd_ccval = hctx->ccid3hctx_last_win_count; |
| @@ -606,12 +602,11 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, | |||
| 606 | unsigned char *value) | 602 | unsigned char *value) |
| 607 | { | 603 | { |
| 608 | int rc = 0; | 604 | int rc = 0; |
| 609 | struct dccp_sock *dp = dccp_sk(sk); | 605 | const struct dccp_sock *dp = dccp_sk(sk); |
| 610 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 606 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
| 611 | struct ccid3_options_received *opt_recv; | 607 | struct ccid3_options_received *opt_recv; |
| 612 | 608 | ||
| 613 | if (hctx == NULL) | 609 | BUG_ON(hctx == NULL); |
| 614 | return 0; | ||
| 615 | 610 | ||
| 616 | opt_recv = &hctx->ccid3hctx_options_received; | 611 | opt_recv = &hctx->ccid3hctx_options_received; |
| 617 | 612 | ||
| @@ -625,10 +620,10 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, | |||
| 625 | 620 | ||
| 626 | switch (option) { | 621 | switch (option) { |
| 627 | case TFRC_OPT_LOSS_EVENT_RATE: | 622 | case TFRC_OPT_LOSS_EVENT_RATE: |
| 628 | if (len != 4) { | 623 | if (unlikely(len != 4)) { |
| 629 | ccid3_pr_debug("%s, sk=%p, invalid len for " | 624 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, invalid " |
| 630 | "TFRC_OPT_LOSS_EVENT_RATE\n", | 625 | "len for TFRC_OPT_LOSS_EVENT_RATE\n", |
| 631 | dccp_role(sk), sk); | 626 | __FUNCTION__, dccp_role(sk), sk); |
| 632 | rc = -EINVAL; | 627 | rc = -EINVAL; |
| 633 | } else { | 628 | } else { |
| 634 | opt_recv->ccid3or_loss_event_rate = ntohl(*(u32 *)value); | 629 | opt_recv->ccid3or_loss_event_rate = ntohl(*(u32 *)value); |
| @@ -646,10 +641,10 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, | |||
| 646 | opt_recv->ccid3or_loss_intervals_len); | 641 | opt_recv->ccid3or_loss_intervals_len); |
| 647 | break; | 642 | break; |
| 648 | case TFRC_OPT_RECEIVE_RATE: | 643 | case TFRC_OPT_RECEIVE_RATE: |
| 649 | if (len != 4) { | 644 | if (unlikely(len != 4)) { |
| 650 | ccid3_pr_debug("%s, sk=%p, invalid len for " | 645 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, invalid " |
| 651 | "TFRC_OPT_RECEIVE_RATE\n", | 646 | "len for TFRC_OPT_RECEIVE_RATE\n", |
| 652 | dccp_role(sk), sk); | 647 | __FUNCTION__, dccp_role(sk), sk); |
| 653 | rc = -EINVAL; | 648 | rc = -EINVAL; |
| 654 | } else { | 649 | } else { |
| 655 | opt_recv->ccid3or_receive_rate = ntohl(*(u32 *)value); | 650 | opt_recv->ccid3or_receive_rate = ntohl(*(u32 *)value); |
| @@ -668,13 +663,11 @@ static int ccid3_hc_tx_init(struct sock *sk) | |||
| 668 | struct dccp_sock *dp = dccp_sk(sk); | 663 | struct dccp_sock *dp = dccp_sk(sk); |
| 669 | struct ccid3_hc_tx_sock *hctx; | 664 | struct ccid3_hc_tx_sock *hctx; |
| 670 | 665 | ||
| 671 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | 666 | dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx), gfp_any()); |
| 672 | 667 | if (dp->dccps_hc_tx_ccid_private == NULL) | |
| 673 | hctx = dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx), | ||
| 674 | gfp_any()); | ||
| 675 | if (hctx == NULL) | ||
| 676 | return -ENOMEM; | 668 | return -ENOMEM; |
| 677 | 669 | ||
| 670 | hctx = ccid3_hc_tx_sk(sk); | ||
| 678 | memset(hctx, 0, sizeof(*hctx)); | 671 | memset(hctx, 0, sizeof(*hctx)); |
| 679 | 672 | ||
| 680 | if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && | 673 | if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && |
| @@ -696,9 +689,8 @@ static int ccid3_hc_tx_init(struct sock *sk) | |||
| 696 | static void ccid3_hc_tx_exit(struct sock *sk) | 689 | static void ccid3_hc_tx_exit(struct sock *sk) |
| 697 | { | 690 | { |
| 698 | struct dccp_sock *dp = dccp_sk(sk); | 691 | struct dccp_sock *dp = dccp_sk(sk); |
| 699 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 692 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
| 700 | 693 | ||
| 701 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | ||
| 702 | BUG_ON(hctx == NULL); | 694 | BUG_ON(hctx == NULL); |
| 703 | 695 | ||
| 704 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_TERM); | 696 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_TERM); |
| @@ -738,8 +730,7 @@ static const char *ccid3_rx_state_name(enum ccid3_hc_rx_states state) | |||
| 738 | static inline void ccid3_hc_rx_set_state(struct sock *sk, | 730 | static inline void ccid3_hc_rx_set_state(struct sock *sk, |
| 739 | enum ccid3_hc_rx_states state) | 731 | enum ccid3_hc_rx_states state) |
| 740 | { | 732 | { |
| 741 | struct dccp_sock *dp = dccp_sk(sk); | 733 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
| 742 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
| 743 | enum ccid3_hc_rx_states oldstate = hcrx->ccid3hcrx_state; | 734 | enum ccid3_hc_rx_states oldstate = hcrx->ccid3hcrx_state; |
| 744 | 735 | ||
| 745 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", | 736 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", |
| @@ -751,14 +742,14 @@ static inline void ccid3_hc_rx_set_state(struct sock *sk, | |||
| 751 | 742 | ||
| 752 | static void ccid3_hc_rx_send_feedback(struct sock *sk) | 743 | static void ccid3_hc_rx_send_feedback(struct sock *sk) |
| 753 | { | 744 | { |
| 745 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); | ||
| 754 | struct dccp_sock *dp = dccp_sk(sk); | 746 | struct dccp_sock *dp = dccp_sk(sk); |
| 755 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
| 756 | struct dccp_rx_hist_entry *packet; | 747 | struct dccp_rx_hist_entry *packet; |
| 757 | struct timeval now; | 748 | struct timeval now; |
| 758 | 749 | ||
| 759 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | 750 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); |
| 760 | 751 | ||
| 761 | do_gettimeofday(&now); | 752 | dccp_timestamp(sk, &now); |
| 762 | 753 | ||
| 763 | switch (hcrx->ccid3hcrx_state) { | 754 | switch (hcrx->ccid3hcrx_state) { |
| 764 | case TFRC_RSTATE_NO_DATA: | 755 | case TFRC_RSTATE_NO_DATA: |
| @@ -767,11 +758,8 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) | |||
| 767 | case TFRC_RSTATE_DATA: { | 758 | case TFRC_RSTATE_DATA: { |
| 768 | const u32 delta = timeval_delta(&now, | 759 | const u32 delta = timeval_delta(&now, |
| 769 | &hcrx->ccid3hcrx_tstamp_last_feedback); | 760 | &hcrx->ccid3hcrx_tstamp_last_feedback); |
| 770 | 761 | hcrx->ccid3hcrx_x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv, | |
| 771 | hcrx->ccid3hcrx_x_recv = (hcrx->ccid3hcrx_bytes_recv * | 762 | delta); |
| 772 | USEC_PER_SEC); | ||
| 773 | if (likely(delta > 1)) | ||
| 774 | hcrx->ccid3hcrx_x_recv /= delta; | ||
| 775 | } | 763 | } |
| 776 | break; | 764 | break; |
| 777 | default: | 765 | default: |
| @@ -782,10 +770,10 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) | |||
| 782 | } | 770 | } |
| 783 | 771 | ||
| 784 | packet = dccp_rx_hist_find_data_packet(&hcrx->ccid3hcrx_hist); | 772 | packet = dccp_rx_hist_find_data_packet(&hcrx->ccid3hcrx_hist); |
| 785 | if (packet == NULL) { | 773 | if (unlikely(packet == NULL)) { |
| 786 | printk(KERN_CRIT "%s: %s, sk=%p, no data packet in history!\n", | 774 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, no data packet " |
| 787 | __FUNCTION__, dccp_role(sk), sk); | 775 | "in history!\n", |
| 788 | dump_stack(); | 776 | __FUNCTION__, dccp_role(sk), sk); |
| 789 | return; | 777 | return; |
| 790 | } | 778 | } |
| 791 | 779 | ||
| @@ -801,17 +789,18 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) | |||
| 801 | hcrx->ccid3hcrx_pinv = ~0; | 789 | hcrx->ccid3hcrx_pinv = ~0; |
| 802 | else | 790 | else |
| 803 | hcrx->ccid3hcrx_pinv = 1000000 / hcrx->ccid3hcrx_p; | 791 | hcrx->ccid3hcrx_pinv = 1000000 / hcrx->ccid3hcrx_p; |
| 792 | dp->dccps_hc_rx_insert_options = 1; | ||
| 804 | dccp_send_ack(sk); | 793 | dccp_send_ack(sk); |
| 805 | } | 794 | } |
| 806 | 795 | ||
| 807 | static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) | 796 | static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) |
| 808 | { | 797 | { |
| 809 | const struct dccp_sock *dp = dccp_sk(sk); | 798 | const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
| 810 | u32 x_recv, pinv; | 799 | u32 x_recv, pinv; |
| 811 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
| 812 | 800 | ||
| 813 | if (hcrx == NULL || !(sk->sk_state == DCCP_OPEN || | 801 | BUG_ON(hcrx == NULL); |
| 814 | sk->sk_state == DCCP_PARTOPEN)) | 802 | |
| 803 | if (!(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)) | ||
| 815 | return; | 804 | return; |
| 816 | 805 | ||
| 817 | DCCP_SKB_CB(skb)->dccpd_ccval = hcrx->ccid3hcrx_last_counter; | 806 | DCCP_SKB_CB(skb)->dccpd_ccval = hcrx->ccid3hcrx_last_counter; |
| @@ -837,8 +826,7 @@ static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) | |||
| 837 | 826 | ||
| 838 | static u32 ccid3_hc_rx_calc_first_li(struct sock *sk) | 827 | static u32 ccid3_hc_rx_calc_first_li(struct sock *sk) |
| 839 | { | 828 | { |
| 840 | struct dccp_sock *dp = dccp_sk(sk); | 829 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
| 841 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
| 842 | struct dccp_rx_hist_entry *entry, *next, *tail = NULL; | 830 | struct dccp_rx_hist_entry *entry, *next, *tail = NULL; |
| 843 | u32 rtt, delta, x_recv, fval, p, tmp2; | 831 | u32 rtt, delta, x_recv, fval, p, tmp2; |
| 844 | struct timeval tstamp = { 0, }; | 832 | struct timeval tstamp = { 0, }; |
| @@ -869,17 +857,17 @@ static u32 ccid3_hc_rx_calc_first_li(struct sock *sk) | |||
| 869 | } | 857 | } |
| 870 | } | 858 | } |
| 871 | 859 | ||
| 872 | if (step == 0) { | 860 | if (unlikely(step == 0)) { |
| 873 | printk(KERN_CRIT "%s: %s, sk=%p, packet history contains no " | 861 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, packet history " |
| 874 | "data packets!\n", | 862 | "contains no data packets!\n", |
| 875 | __FUNCTION__, dccp_role(sk), sk); | 863 | __FUNCTION__, dccp_role(sk), sk); |
| 876 | return ~0; | 864 | return ~0; |
| 877 | } | 865 | } |
| 878 | 866 | ||
| 879 | if (interval == 0) { | 867 | if (unlikely(interval == 0)) { |
| 880 | ccid3_pr_debug("%s, sk=%p, Could not find a win_count " | 868 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, Could not find a " |
| 881 | "interval > 0. Defaulting to 1\n", | 869 | "win_count interval > 0. Defaulting to 1\n", |
| 882 | dccp_role(sk), sk); | 870 | __FUNCTION__, dccp_role(sk), sk); |
| 883 | interval = 1; | 871 | interval = 1; |
| 884 | } | 872 | } |
| 885 | found: | 873 | found: |
| @@ -889,10 +877,9 @@ found: | |||
| 889 | if (rtt == 0) | 877 | if (rtt == 0) |
| 890 | rtt = 1; | 878 | rtt = 1; |
| 891 | 879 | ||
| 892 | delta = timeval_now_delta(&hcrx->ccid3hcrx_tstamp_last_feedback); | 880 | dccp_timestamp(sk, &tstamp); |
| 893 | x_recv = hcrx->ccid3hcrx_bytes_recv * USEC_PER_SEC; | 881 | delta = timeval_delta(&tstamp, &hcrx->ccid3hcrx_tstamp_last_feedback); |
| 894 | if (likely(delta > 1)) | 882 | x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv, delta); |
| 895 | x_recv /= delta; | ||
| 896 | 883 | ||
| 897 | tmp1 = (u64)x_recv * (u64)rtt; | 884 | tmp1 = (u64)x_recv * (u64)rtt; |
| 898 | do_div(tmp1,10000000); | 885 | do_div(tmp1,10000000); |
| @@ -911,8 +898,7 @@ found: | |||
| 911 | 898 | ||
| 912 | static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss) | 899 | static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss) |
| 913 | { | 900 | { |
| 914 | struct dccp_sock *dp = dccp_sk(sk); | 901 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
| 915 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
| 916 | 902 | ||
| 917 | if (seq_loss != DCCP_MAX_SEQNO + 1 && | 903 | if (seq_loss != DCCP_MAX_SEQNO + 1 && |
| 918 | list_empty(&hcrx->ccid3hcrx_li_hist)) { | 904 | list_empty(&hcrx->ccid3hcrx_li_hist)) { |
| @@ -924,14 +910,14 @@ static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss) | |||
| 924 | if (li_tail == NULL) | 910 | if (li_tail == NULL) |
| 925 | return; | 911 | return; |
| 926 | li_tail->dccplih_interval = ccid3_hc_rx_calc_first_li(sk); | 912 | li_tail->dccplih_interval = ccid3_hc_rx_calc_first_li(sk); |
| 927 | } | 913 | } else |
| 928 | /* FIXME: find end of interval */ | 914 | LIMIT_NETDEBUG(KERN_WARNING "%s: FIXME: find end of " |
| 915 | "interval\n", __FUNCTION__); | ||
| 929 | } | 916 | } |
| 930 | 917 | ||
| 931 | static void ccid3_hc_rx_detect_loss(struct sock *sk) | 918 | static void ccid3_hc_rx_detect_loss(struct sock *sk) |
| 932 | { | 919 | { |
| 933 | struct dccp_sock *dp = dccp_sk(sk); | 920 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
| 934 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
| 935 | u8 win_loss; | 921 | u8 win_loss; |
| 936 | const u64 seq_loss = dccp_rx_hist_detect_loss(&hcrx->ccid3hcrx_hist, | 922 | const u64 seq_loss = dccp_rx_hist_detect_loss(&hcrx->ccid3hcrx_hist, |
| 937 | &hcrx->ccid3hcrx_li_hist, | 923 | &hcrx->ccid3hcrx_li_hist, |
| @@ -942,22 +928,19 @@ static void ccid3_hc_rx_detect_loss(struct sock *sk) | |||
| 942 | 928 | ||
| 943 | static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | 929 | static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) |
| 944 | { | 930 | { |
| 945 | struct dccp_sock *dp = dccp_sk(sk); | 931 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
| 946 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
| 947 | const struct dccp_options_received *opt_recv; | 932 | const struct dccp_options_received *opt_recv; |
| 948 | struct dccp_rx_hist_entry *packet; | 933 | struct dccp_rx_hist_entry *packet; |
| 949 | struct timeval now; | 934 | struct timeval now; |
| 950 | u8 win_count; | 935 | u8 win_count; |
| 951 | u32 p_prev; | 936 | u32 p_prev, r_sample, t_elapsed; |
| 952 | int ins; | 937 | int ins; |
| 953 | 938 | ||
| 954 | if (hcrx == NULL) | 939 | BUG_ON(hcrx == NULL || |
| 955 | return; | 940 | !(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA || |
| 956 | |||
| 957 | BUG_ON(!(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA || | ||
| 958 | hcrx->ccid3hcrx_state == TFRC_RSTATE_DATA)); | 941 | hcrx->ccid3hcrx_state == TFRC_RSTATE_DATA)); |
| 959 | 942 | ||
| 960 | opt_recv = &dp->dccps_options_received; | 943 | opt_recv = &dccp_sk(sk)->dccps_options_received; |
| 961 | 944 | ||
| 962 | switch (DCCP_SKB_CB(skb)->dccpd_type) { | 945 | switch (DCCP_SKB_CB(skb)->dccpd_type) { |
| 963 | case DCCP_PKT_ACK: | 946 | case DCCP_PKT_ACK: |
| @@ -967,10 +950,24 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
| 967 | if (opt_recv->dccpor_timestamp_echo == 0) | 950 | if (opt_recv->dccpor_timestamp_echo == 0) |
| 968 | break; | 951 | break; |
| 969 | p_prev = hcrx->ccid3hcrx_rtt; | 952 | p_prev = hcrx->ccid3hcrx_rtt; |
| 970 | do_gettimeofday(&now); | 953 | dccp_timestamp(sk, &now); |
| 971 | hcrx->ccid3hcrx_rtt = timeval_usecs(&now) - | 954 | timeval_sub_usecs(&now, opt_recv->dccpor_timestamp_echo * 10); |
| 972 | (opt_recv->dccpor_timestamp_echo - | 955 | r_sample = timeval_usecs(&now); |
| 973 | opt_recv->dccpor_elapsed_time) * 10; | 956 | t_elapsed = opt_recv->dccpor_elapsed_time * 10; |
| 957 | |||
| 958 | if (unlikely(r_sample <= t_elapsed)) | ||
| 959 | LIMIT_NETDEBUG(KERN_WARNING "%s: r_sample=%uus, " | ||
| 960 | "t_elapsed=%uus\n", | ||
| 961 | __FUNCTION__, r_sample, t_elapsed); | ||
| 962 | else | ||
| 963 | r_sample -= t_elapsed; | ||
| 964 | |||
| 965 | if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA) | ||
| 966 | hcrx->ccid3hcrx_rtt = r_sample; | ||
| 967 | else | ||
| 968 | hcrx->ccid3hcrx_rtt = (hcrx->ccid3hcrx_rtt * 9) / 10 + | ||
| 969 | r_sample / 10; | ||
| 970 | |||
| 974 | if (p_prev != hcrx->ccid3hcrx_rtt) | 971 | if (p_prev != hcrx->ccid3hcrx_rtt) |
| 975 | ccid3_pr_debug("%s, New RTT=%luus, elapsed time=%u\n", | 972 | ccid3_pr_debug("%s, New RTT=%luus, elapsed time=%u\n", |
| 976 | dccp_role(sk), hcrx->ccid3hcrx_rtt, | 973 | dccp_role(sk), hcrx->ccid3hcrx_rtt, |
| @@ -978,19 +975,16 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
| 978 | break; | 975 | break; |
| 979 | case DCCP_PKT_DATA: | 976 | case DCCP_PKT_DATA: |
| 980 | break; | 977 | break; |
| 981 | default: | 978 | default: /* We're not interested in other packet types, move along */ |
| 982 | ccid3_pr_debug("%s, sk=%p, not DATA/DATAACK/ACK packet(%s)\n", | ||
| 983 | dccp_role(sk), sk, | ||
| 984 | dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type)); | ||
| 985 | return; | 979 | return; |
| 986 | } | 980 | } |
| 987 | 981 | ||
| 988 | packet = dccp_rx_hist_entry_new(ccid3_rx_hist, opt_recv->dccpor_ndp, | 982 | packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp, |
| 989 | skb, SLAB_ATOMIC); | 983 | skb, SLAB_ATOMIC); |
| 990 | if (packet == NULL) { | 984 | if (unlikely(packet == NULL)) { |
| 991 | ccid3_pr_debug("%s, sk=%p, Not enough mem to add rx packet " | 985 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, Not enough mem to " |
| 992 | "to history (consider it lost)!", | 986 | "add rx packet to history, consider it lost!\n", |
| 993 | dccp_role(sk), sk); | 987 | __FUNCTION__, dccp_role(sk), sk); |
| 994 | return; | 988 | return; |
| 995 | } | 989 | } |
| 996 | 990 | ||
| @@ -1017,7 +1011,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
| 1017 | if (ins != 0) | 1011 | if (ins != 0) |
| 1018 | break; | 1012 | break; |
| 1019 | 1013 | ||
| 1020 | do_gettimeofday(&now); | 1014 | dccp_timestamp(sk, &now); |
| 1021 | if (timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) >= | 1015 | if (timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) >= |
| 1022 | hcrx->ccid3hcrx_rtt) { | 1016 | hcrx->ccid3hcrx_rtt) { |
| 1023 | hcrx->ccid3hcrx_tstamp_last_ack = now; | 1017 | hcrx->ccid3hcrx_tstamp_last_ack = now; |
| @@ -1056,11 +1050,11 @@ static int ccid3_hc_rx_init(struct sock *sk) | |||
| 1056 | 1050 | ||
| 1057 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | 1051 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); |
| 1058 | 1052 | ||
| 1059 | hcrx = dp->dccps_hc_rx_ccid_private = kmalloc(sizeof(*hcrx), | 1053 | dp->dccps_hc_rx_ccid_private = kmalloc(sizeof(*hcrx), gfp_any()); |
| 1060 | gfp_any()); | 1054 | if (dp->dccps_hc_rx_ccid_private == NULL) |
| 1061 | if (hcrx == NULL) | ||
| 1062 | return -ENOMEM; | 1055 | return -ENOMEM; |
| 1063 | 1056 | ||
| 1057 | hcrx = ccid3_hc_rx_sk(sk); | ||
| 1064 | memset(hcrx, 0, sizeof(*hcrx)); | 1058 | memset(hcrx, 0, sizeof(*hcrx)); |
| 1065 | 1059 | ||
| 1066 | if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && | 1060 | if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && |
| @@ -1072,23 +1066,18 @@ static int ccid3_hc_rx_init(struct sock *sk) | |||
| 1072 | hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; | 1066 | hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; |
| 1073 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); | 1067 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); |
| 1074 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist); | 1068 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist); |
| 1075 | /* | 1069 | dccp_timestamp(sk, &hcrx->ccid3hcrx_tstamp_last_ack); |
| 1076 | * XXX this seems to be paranoid, need to think more about this, for | 1070 | hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack; |
| 1077 | * now start with something different than zero. -acme | 1071 | hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */ |
| 1078 | */ | ||
| 1079 | hcrx->ccid3hcrx_rtt = USEC_PER_SEC / 5; | ||
| 1080 | return 0; | 1072 | return 0; |
| 1081 | } | 1073 | } |
| 1082 | 1074 | ||
| 1083 | static void ccid3_hc_rx_exit(struct sock *sk) | 1075 | static void ccid3_hc_rx_exit(struct sock *sk) |
| 1084 | { | 1076 | { |
| 1077 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); | ||
| 1085 | struct dccp_sock *dp = dccp_sk(sk); | 1078 | struct dccp_sock *dp = dccp_sk(sk); |
| 1086 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
| 1087 | 1079 | ||
| 1088 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | 1080 | BUG_ON(hcrx == NULL); |
| 1089 | |||
| 1090 | if (hcrx == NULL) | ||
| 1091 | return; | ||
| 1092 | 1081 | ||
| 1093 | ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM); | 1082 | ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM); |
| 1094 | 1083 | ||
| @@ -1104,12 +1093,14 @@ static void ccid3_hc_rx_exit(struct sock *sk) | |||
| 1104 | 1093 | ||
| 1105 | static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) | 1094 | static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) |
| 1106 | { | 1095 | { |
| 1107 | const struct dccp_sock *dp = dccp_sk(sk); | 1096 | const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
| 1108 | const struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
| 1109 | 1097 | ||
| 1110 | if (hcrx == NULL) | 1098 | /* Listen socks doesn't have a private CCID block */ |
| 1099 | if (sk->sk_state == DCCP_LISTEN) | ||
| 1111 | return; | 1100 | return; |
| 1112 | 1101 | ||
| 1102 | BUG_ON(hcrx == NULL); | ||
| 1103 | |||
| 1113 | info->tcpi_ca_state = hcrx->ccid3hcrx_state; | 1104 | info->tcpi_ca_state = hcrx->ccid3hcrx_state; |
| 1114 | info->tcpi_options |= TCPI_OPT_TIMESTAMPS; | 1105 | info->tcpi_options |= TCPI_OPT_TIMESTAMPS; |
| 1115 | info->tcpi_rcv_rtt = hcrx->ccid3hcrx_rtt; | 1106 | info->tcpi_rcv_rtt = hcrx->ccid3hcrx_rtt; |
| @@ -1117,12 +1108,14 @@ static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) | |||
| 1117 | 1108 | ||
| 1118 | static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info) | 1109 | static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info) |
| 1119 | { | 1110 | { |
| 1120 | const struct dccp_sock *dp = dccp_sk(sk); | 1111 | const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
| 1121 | const struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | ||
| 1122 | 1112 | ||
| 1123 | if (hctx == NULL) | 1113 | /* Listen socks doesn't have a private CCID block */ |
| 1114 | if (sk->sk_state == DCCP_LISTEN) | ||
| 1124 | return; | 1115 | return; |
| 1125 | 1116 | ||
| 1117 | BUG_ON(hctx == NULL); | ||
| 1118 | |||
| 1126 | info->tcpi_rto = hctx->ccid3hctx_t_rto; | 1119 | info->tcpi_rto = hctx->ccid3hctx_t_rto; |
| 1127 | info->tcpi_rtt = hctx->ccid3hctx_rtt; | 1120 | info->tcpi_rtt = hctx->ccid3hctx_rtt; |
| 1128 | } | 1121 | } |
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h index ee8cbace6630..eb248778eea3 100644 --- a/net/dccp/ccids/ccid3.h +++ b/net/dccp/ccids/ccid3.h | |||
| @@ -48,6 +48,8 @@ | |||
| 48 | /* Two seconds as per CCID3 spec */ | 48 | /* Two seconds as per CCID3 spec */ |
| 49 | #define TFRC_INITIAL_TIMEOUT (2 * USEC_PER_SEC) | 49 | #define TFRC_INITIAL_TIMEOUT (2 * USEC_PER_SEC) |
| 50 | 50 | ||
| 51 | #define TFRC_INITIAL_IPI (USEC_PER_SEC / 4) | ||
| 52 | |||
| 51 | /* In usecs - half the scheduling granularity as per RFC3448 4.6 */ | 53 | /* In usecs - half the scheduling granularity as per RFC3448 4.6 */ |
| 52 | #define TFRC_OPSYS_HALF_TIME_GRAN (USEC_PER_SEC / (2 * HZ)) | 54 | #define TFRC_OPSYS_HALF_TIME_GRAN (USEC_PER_SEC / (2 * HZ)) |
| 53 | 55 | ||
| @@ -115,7 +117,7 @@ struct ccid3_hc_rx_sock { | |||
| 115 | u64 ccid3hcrx_seqno_last_counter:48, | 117 | u64 ccid3hcrx_seqno_last_counter:48, |
| 116 | ccid3hcrx_state:8, | 118 | ccid3hcrx_state:8, |
| 117 | ccid3hcrx_last_counter:4; | 119 | ccid3hcrx_last_counter:4; |
| 118 | unsigned long ccid3hcrx_rtt; | 120 | u32 ccid3hcrx_rtt; |
| 119 | u32 ccid3hcrx_p; | 121 | u32 ccid3hcrx_p; |
| 120 | u32 ccid3hcrx_bytes_recv; | 122 | u32 ccid3hcrx_bytes_recv; |
| 121 | struct timeval ccid3hcrx_tstamp_last_feedback; | 123 | struct timeval ccid3hcrx_tstamp_last_feedback; |
| @@ -128,10 +130,14 @@ struct ccid3_hc_rx_sock { | |||
| 128 | u32 ccid3hcrx_x_recv; | 130 | u32 ccid3hcrx_x_recv; |
| 129 | }; | 131 | }; |
| 130 | 132 | ||
| 131 | #define ccid3_hc_tx_field(s,field) (s->dccps_hc_tx_ccid_private == NULL ? 0 : \ | 133 | static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk) |
| 132 | ((struct ccid3_hc_tx_sock *)s->dccps_hc_tx_ccid_private)->ccid3hctx_##field) | 134 | { |
| 135 | return dccp_sk(sk)->dccps_hc_tx_ccid_private; | ||
| 136 | } | ||
| 133 | 137 | ||
| 134 | #define ccid3_hc_rx_field(s,field) (s->dccps_hc_rx_ccid_private == NULL ? 0 : \ | 138 | static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk) |
| 135 | ((struct ccid3_hc_rx_sock *)s->dccps_hc_rx_ccid_private)->ccid3hcrx_##field) | 139 | { |
| 140 | return dccp_sk(sk)->dccps_hc_rx_ccid_private; | ||
| 141 | } | ||
| 136 | 142 | ||
| 137 | #endif /* _DCCP_CCID3_H_ */ | 143 | #endif /* _DCCP_CCID3_H_ */ |
diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h index fb90a91aa93d..b375ebdb7dcf 100644 --- a/net/dccp/ccids/lib/packet_history.h +++ b/net/dccp/ccids/lib/packet_history.h | |||
| @@ -134,6 +134,7 @@ static inline struct dccp_tx_hist_entry * | |||
| 134 | 134 | ||
| 135 | static inline struct dccp_rx_hist_entry * | 135 | static inline struct dccp_rx_hist_entry * |
| 136 | dccp_rx_hist_entry_new(struct dccp_rx_hist *hist, | 136 | dccp_rx_hist_entry_new(struct dccp_rx_hist *hist, |
| 137 | const struct sock *sk, | ||
| 137 | const u32 ndp, | 138 | const u32 ndp, |
| 138 | const struct sk_buff *skb, | 139 | const struct sk_buff *skb, |
| 139 | const unsigned int __nocast prio) | 140 | const unsigned int __nocast prio) |
| @@ -148,7 +149,7 @@ static inline struct dccp_rx_hist_entry * | |||
| 148 | entry->dccphrx_ccval = dh->dccph_ccval; | 149 | entry->dccphrx_ccval = dh->dccph_ccval; |
| 149 | entry->dccphrx_type = dh->dccph_type; | 150 | entry->dccphrx_type = dh->dccph_type; |
| 150 | entry->dccphrx_ndp = ndp; | 151 | entry->dccphrx_ndp = ndp; |
| 151 | do_gettimeofday(&(entry->dccphrx_tstamp)); | 152 | dccp_timestamp(sk, &entry->dccphrx_tstamp); |
| 152 | } | 153 | } |
| 153 | 154 | ||
| 154 | return entry; | 155 | return entry; |
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index 33456c0d5937..95c4630b3b18 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h | |||
| @@ -426,10 +426,13 @@ extern struct dccp_ackpkts * | |||
| 426 | dccp_ackpkts_alloc(unsigned int len, | 426 | dccp_ackpkts_alloc(unsigned int len, |
| 427 | const unsigned int __nocast priority); | 427 | const unsigned int __nocast priority); |
| 428 | extern void dccp_ackpkts_free(struct dccp_ackpkts *ap); | 428 | extern void dccp_ackpkts_free(struct dccp_ackpkts *ap); |
| 429 | extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state); | 429 | extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, const struct sock *sk, |
| 430 | u64 ackno, u8 state); | ||
| 430 | extern void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap, | 431 | extern void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap, |
| 431 | struct sock *sk, u64 ackno); | 432 | struct sock *sk, u64 ackno); |
| 432 | 433 | ||
| 434 | extern void dccp_timestamp(const struct sock *sk, struct timeval *tv); | ||
| 435 | |||
| 433 | static inline suseconds_t timeval_usecs(const struct timeval *tv) | 436 | static inline suseconds_t timeval_usecs(const struct timeval *tv) |
| 434 | { | 437 | { |
| 435 | return tv->tv_sec * USEC_PER_SEC + tv->tv_usec; | 438 | return tv->tv_sec * USEC_PER_SEC + tv->tv_usec; |
| @@ -468,17 +471,6 @@ static inline void timeval_sub_usecs(struct timeval *tv, | |||
| 468 | } | 471 | } |
| 469 | } | 472 | } |
| 470 | 473 | ||
| 471 | /* | ||
| 472 | * Returns the difference in usecs between timeval | ||
| 473 | * passed in and current time | ||
| 474 | */ | ||
| 475 | static inline suseconds_t timeval_now_delta(const struct timeval *tv) | ||
| 476 | { | ||
| 477 | struct timeval now; | ||
| 478 | do_gettimeofday(&now); | ||
| 479 | return timeval_delta(&now, tv); | ||
| 480 | } | ||
| 481 | |||
| 482 | #ifdef CONFIG_IP_DCCP_DEBUG | 474 | #ifdef CONFIG_IP_DCCP_DEBUG |
| 483 | extern void dccp_ackvector_print(const u64 ackno, | 475 | extern void dccp_ackvector_print(const u64 ackno, |
| 484 | const unsigned char *vector, int len); | 476 | const unsigned char *vector, int len); |
diff --git a/net/dccp/input.c b/net/dccp/input.c index ef29cef1dafe..c60bc3433f5e 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c | |||
| @@ -170,7 +170,7 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb, | |||
| 170 | if (dp->dccps_options.dccpo_send_ack_vector) { | 170 | if (dp->dccps_options.dccpo_send_ack_vector) { |
| 171 | struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; | 171 | struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; |
| 172 | 172 | ||
| 173 | if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, | 173 | if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, sk, |
| 174 | DCCP_SKB_CB(skb)->dccpd_seq, | 174 | DCCP_SKB_CB(skb)->dccpd_seq, |
| 175 | DCCP_ACKPKTS_STATE_RECEIVED)) { | 175 | DCCP_ACKPKTS_STATE_RECEIVED)) { |
| 176 | LIMIT_NETDEBUG(KERN_WARNING "DCCP: acknowledgeable " | 176 | LIMIT_NETDEBUG(KERN_WARNING "DCCP: acknowledgeable " |
| @@ -498,7 +498,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, | |||
| 498 | * DCCP_ACKPKTS_STATE_ECN_MARKED | 498 | * DCCP_ACKPKTS_STATE_ECN_MARKED |
| 499 | */ | 499 | */ |
| 500 | if (dp->dccps_options.dccpo_send_ack_vector) { | 500 | if (dp->dccps_options.dccpo_send_ack_vector) { |
| 501 | if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, | 501 | if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, sk, |
| 502 | DCCP_SKB_CB(skb)->dccpd_seq, | 502 | DCCP_SKB_CB(skb)->dccpd_seq, |
| 503 | DCCP_ACKPKTS_STATE_RECEIVED)) | 503 | DCCP_ACKPKTS_STATE_RECEIVED)) |
| 504 | goto discard; | 504 | goto discard; |
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 3fc75dbee4b8..2afaa464e7f0 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
| @@ -641,16 +641,12 @@ int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code) | |||
| 641 | 641 | ||
| 642 | skb = dccp_make_reset(sk, sk->sk_dst_cache, code); | 642 | skb = dccp_make_reset(sk, sk->sk_dst_cache, code); |
| 643 | if (skb != NULL) { | 643 | if (skb != NULL) { |
| 644 | const struct dccp_sock *dp = dccp_sk(sk); | ||
| 645 | const struct inet_sock *inet = inet_sk(sk); | 644 | const struct inet_sock *inet = inet_sk(sk); |
| 646 | 645 | ||
| 647 | err = ip_build_and_send_pkt(skb, sk, | 646 | err = ip_build_and_send_pkt(skb, sk, |
| 648 | inet->saddr, inet->daddr, NULL); | 647 | inet->saddr, inet->daddr, NULL); |
| 649 | if (err == NET_XMIT_CN) | 648 | if (err == NET_XMIT_CN) |
| 650 | err = 0; | 649 | err = 0; |
| 651 | |||
| 652 | ccid_hc_rx_exit(dp->dccps_hc_rx_ccid, sk); | ||
| 653 | ccid_hc_tx_exit(dp->dccps_hc_tx_ccid, sk); | ||
| 654 | } | 650 | } |
| 655 | 651 | ||
| 656 | return err; | 652 | return err; |
| @@ -1243,6 +1239,7 @@ static int dccp_v4_init_sock(struct sock *sk) | |||
| 1243 | static int dccp_ctl_socket_init = 1; | 1239 | static int dccp_ctl_socket_init = 1; |
| 1244 | 1240 | ||
| 1245 | dccp_options_init(&dp->dccps_options); | 1241 | dccp_options_init(&dp->dccps_options); |
| 1242 | do_gettimeofday(&dp->dccps_epoch); | ||
| 1246 | 1243 | ||
| 1247 | if (dp->dccps_options.dccpo_send_ack_vector) { | 1244 | if (dp->dccps_options.dccpo_send_ack_vector) { |
| 1248 | dp->dccps_hc_rx_ackpkts = | 1245 | dp->dccps_hc_rx_ackpkts = |
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c index ce5dff4ac22e..18461bc04cbe 100644 --- a/net/dccp/minisocks.c +++ b/net/dccp/minisocks.c | |||
| @@ -96,6 +96,7 @@ struct sock *dccp_create_openreq_child(struct sock *sk, | |||
| 96 | newdp->dccps_hc_rx_ackpkts = NULL; | 96 | newdp->dccps_hc_rx_ackpkts = NULL; |
| 97 | newdp->dccps_role = DCCP_ROLE_SERVER; | 97 | newdp->dccps_role = DCCP_ROLE_SERVER; |
| 98 | newicsk->icsk_rto = DCCP_TIMEOUT_INIT; | 98 | newicsk->icsk_rto = DCCP_TIMEOUT_INIT; |
| 99 | do_gettimeofday(&newdp->dccps_epoch); | ||
| 99 | 100 | ||
| 100 | if (newdp->dccps_options.dccpo_send_ack_vector) { | 101 | if (newdp->dccps_options.dccpo_send_ack_vector) { |
| 101 | newdp->dccps_hc_rx_ackpkts = | 102 | newdp->dccps_hc_rx_ackpkts = |
diff --git a/net/dccp/options.c b/net/dccp/options.c index 382c5894acb2..d4c4242d8dd7 100644 --- a/net/dccp/options.c +++ b/net/dccp/options.c | |||
| @@ -72,6 +72,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) | |||
| 72 | struct dccp_options_received *opt_recv = &dp->dccps_options_received; | 72 | struct dccp_options_received *opt_recv = &dp->dccps_options_received; |
| 73 | unsigned char opt, len; | 73 | unsigned char opt, len; |
| 74 | unsigned char *value; | 74 | unsigned char *value; |
| 75 | u32 elapsed_time; | ||
| 75 | 76 | ||
| 76 | memset(opt_recv, 0, sizeof(*opt_recv)); | 77 | memset(opt_recv, 0, sizeof(*opt_recv)); |
| 77 | 78 | ||
| @@ -139,7 +140,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) | |||
| 139 | opt_recv->dccpor_timestamp = ntohl(*(u32 *)value); | 140 | opt_recv->dccpor_timestamp = ntohl(*(u32 *)value); |
| 140 | 141 | ||
| 141 | dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp; | 142 | dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp; |
| 142 | do_gettimeofday(&dp->dccps_timestamp_time); | 143 | dccp_timestamp(sk, &dp->dccps_timestamp_time); |
| 143 | 144 | ||
| 144 | dccp_pr_debug("%sTIMESTAMP=%u, ackno=%llu\n", | 145 | dccp_pr_debug("%sTIMESTAMP=%u, ackno=%llu\n", |
| 145 | debug_prefix, opt_recv->dccpor_timestamp, | 146 | debug_prefix, opt_recv->dccpor_timestamp, |
| @@ -159,18 +160,18 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) | |||
| 159 | (unsigned long long) | 160 | (unsigned long long) |
| 160 | DCCP_SKB_CB(skb)->dccpd_ack_seq); | 161 | DCCP_SKB_CB(skb)->dccpd_ack_seq); |
| 161 | 162 | ||
| 162 | if (len > 4) { | ||
| 163 | if (len == 6) | ||
| 164 | opt_recv->dccpor_elapsed_time = | ||
| 165 | ntohs(*(u16 *)(value + 4)); | ||
| 166 | else | ||
| 167 | opt_recv->dccpor_elapsed_time = | ||
| 168 | ntohl(*(u32 *)(value + 4)); | ||
| 169 | 163 | ||
| 170 | dccp_pr_debug("%sTIMESTAMP_ECHO ELAPSED_TIME=%d\n", | 164 | if (len == 4) |
| 171 | debug_prefix, | 165 | break; |
| 172 | opt_recv->dccpor_elapsed_time); | 166 | |
| 173 | } | 167 | if (len == 6) |
| 168 | elapsed_time = ntohs(*(u16 *)(value + 4)); | ||
| 169 | else | ||
| 170 | elapsed_time = ntohl(*(u32 *)(value + 4)); | ||
| 171 | |||
| 172 | /* Give precedence to the biggest ELAPSED_TIME */ | ||
| 173 | if (elapsed_time > opt_recv->dccpor_elapsed_time) | ||
| 174 | opt_recv->dccpor_elapsed_time = elapsed_time; | ||
| 174 | break; | 175 | break; |
| 175 | case DCCPO_ELAPSED_TIME: | 176 | case DCCPO_ELAPSED_TIME: |
| 176 | if (len != 2 && len != 4) | 177 | if (len != 2 && len != 4) |
| @@ -180,14 +181,15 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) | |||
| 180 | continue; | 181 | continue; |
| 181 | 182 | ||
| 182 | if (len == 2) | 183 | if (len == 2) |
| 183 | opt_recv->dccpor_elapsed_time = | 184 | elapsed_time = ntohs(*(u16 *)value); |
| 184 | ntohs(*(u16 *)value); | ||
| 185 | else | 185 | else |
| 186 | opt_recv->dccpor_elapsed_time = | 186 | elapsed_time = ntohl(*(u32 *)value); |
| 187 | ntohl(*(u32 *)value); | 187 | |
| 188 | if (elapsed_time > opt_recv->dccpor_elapsed_time) | ||
| 189 | opt_recv->dccpor_elapsed_time = elapsed_time; | ||
| 188 | 190 | ||
| 189 | dccp_pr_debug("%sELAPSED_TIME=%d\n", debug_prefix, | 191 | dccp_pr_debug("%sELAPSED_TIME=%d\n", debug_prefix, |
| 190 | opt_recv->dccpor_elapsed_time); | 192 | elapsed_time); |
| 191 | break; | 193 | break; |
| 192 | /* | 194 | /* |
| 193 | * From draft-ietf-dccp-spec-11.txt: | 195 | * From draft-ietf-dccp-spec-11.txt: |
| @@ -359,9 +361,13 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb) | |||
| 359 | #endif | 361 | #endif |
| 360 | struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; | 362 | struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; |
| 361 | int len = ap->dccpap_buf_vector_len + 2; | 363 | int len = ap->dccpap_buf_vector_len + 2; |
| 362 | const u32 elapsed_time = timeval_now_delta(&ap->dccpap_time) / 10; | 364 | struct timeval now; |
| 365 | u32 elapsed_time; | ||
| 363 | unsigned char *to, *from; | 366 | unsigned char *to, *from; |
| 364 | 367 | ||
| 368 | dccp_timestamp(sk, &now); | ||
| 369 | elapsed_time = timeval_delta(&now, &ap->dccpap_time) / 10; | ||
| 370 | |||
| 365 | if (elapsed_time != 0) | 371 | if (elapsed_time != 0) |
| 366 | dccp_insert_option_elapsed_time(sk, skb, elapsed_time); | 372 | dccp_insert_option_elapsed_time(sk, skb, elapsed_time); |
| 367 | 373 | ||
| @@ -426,13 +432,29 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb) | |||
| 426 | (unsigned long long) ap->dccpap_ack_ackno); | 432 | (unsigned long long) ap->dccpap_ack_ackno); |
| 427 | } | 433 | } |
| 428 | 434 | ||
| 435 | void dccp_timestamp(const struct sock *sk, struct timeval *tv) | ||
| 436 | { | ||
| 437 | const struct dccp_sock *dp = dccp_sk(sk); | ||
| 438 | |||
| 439 | do_gettimeofday(tv); | ||
| 440 | tv->tv_sec -= dp->dccps_epoch.tv_sec; | ||
| 441 | tv->tv_usec -= dp->dccps_epoch.tv_usec; | ||
| 442 | |||
| 443 | while (tv->tv_usec < 0) { | ||
| 444 | tv->tv_sec--; | ||
| 445 | tv->tv_usec += USEC_PER_SEC; | ||
| 446 | } | ||
| 447 | } | ||
| 448 | |||
| 449 | EXPORT_SYMBOL_GPL(dccp_timestamp); | ||
| 450 | |||
| 429 | void dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb) | 451 | void dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb) |
| 430 | { | 452 | { |
| 431 | struct timeval tv; | 453 | struct timeval tv; |
| 432 | u32 now; | 454 | u32 now; |
| 433 | 455 | ||
| 434 | do_gettimeofday(&tv); | 456 | dccp_timestamp(sk, &tv); |
| 435 | now = (tv.tv_sec * USEC_PER_SEC + tv.tv_usec) / 10; | 457 | now = timeval_usecs(&tv) / 10; |
| 436 | /* yes this will overflow but that is the point as we want a | 458 | /* yes this will overflow but that is the point as we want a |
| 437 | * 10 usec 32 bit timer which mean it wraps every 11.9 hours */ | 459 | * 10 usec 32 bit timer which mean it wraps every 11.9 hours */ |
| 438 | 460 | ||
| @@ -450,13 +472,17 @@ static void dccp_insert_option_timestamp_echo(struct sock *sk, | |||
| 450 | const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? | 472 | const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? |
| 451 | "CLIENT TX opt: " : "server TX opt: "; | 473 | "CLIENT TX opt: " : "server TX opt: "; |
| 452 | #endif | 474 | #endif |
| 475 | struct timeval now; | ||
| 453 | u32 tstamp_echo; | 476 | u32 tstamp_echo; |
| 454 | const u32 elapsed_time = | 477 | u32 elapsed_time; |
| 455 | timeval_now_delta(&dp->dccps_timestamp_time) / 10; | 478 | int len, elapsed_time_len; |
| 456 | const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time); | ||
| 457 | const int len = 6 + elapsed_time_len; | ||
| 458 | unsigned char *to; | 479 | unsigned char *to; |
| 459 | 480 | ||
| 481 | dccp_timestamp(sk, &now); | ||
| 482 | elapsed_time = timeval_delta(&now, &dp->dccps_timestamp_time) / 10; | ||
| 483 | elapsed_time_len = dccp_elapsed_time_len(elapsed_time); | ||
| 484 | len = 6 + elapsed_time_len; | ||
| 485 | |||
| 460 | if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { | 486 | if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { |
| 461 | LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert " | 487 | LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert " |
| 462 | "timestamp echo!\n"); | 488 | "timestamp echo!\n"); |
| @@ -505,13 +531,18 @@ void dccp_insert_options(struct sock *sk, struct sk_buff *skb) | |||
| 505 | (dp->dccps_hc_rx_ackpkts->dccpap_buf_ackno != | 531 | (dp->dccps_hc_rx_ackpkts->dccpap_buf_ackno != |
| 506 | DCCP_MAX_SEQNO + 1)) | 532 | DCCP_MAX_SEQNO + 1)) |
| 507 | dccp_insert_option_ack_vector(sk, skb); | 533 | dccp_insert_option_ack_vector(sk, skb); |
| 508 | |||
| 509 | if (dp->dccps_timestamp_echo != 0) | 534 | if (dp->dccps_timestamp_echo != 0) |
| 510 | dccp_insert_option_timestamp_echo(sk, skb); | 535 | dccp_insert_option_timestamp_echo(sk, skb); |
| 511 | } | 536 | } |
| 512 | 537 | ||
| 513 | ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb); | 538 | if (dp->dccps_hc_rx_insert_options) { |
| 514 | ccid_hc_tx_insert_options(dp->dccps_hc_tx_ccid, sk, skb); | 539 | ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb); |
| 540 | dp->dccps_hc_rx_insert_options = 0; | ||
| 541 | } | ||
| 542 | if (dp->dccps_hc_tx_insert_options) { | ||
| 543 | ccid_hc_tx_insert_options(dp->dccps_hc_tx_ccid, sk, skb); | ||
| 544 | dp->dccps_hc_tx_insert_options = 0; | ||
| 545 | } | ||
| 515 | 546 | ||
| 516 | /* XXX: insert other options when appropriate */ | 547 | /* XXX: insert other options when appropriate */ |
| 517 | 548 | ||
| @@ -616,7 +647,8 @@ static inline int dccp_ackpkts_set_buf_head_state(struct dccp_ackpkts *ap, | |||
| 616 | /* | 647 | /* |
| 617 | * Implements the draft-ietf-dccp-spec-11.txt Appendix A | 648 | * Implements the draft-ietf-dccp-spec-11.txt Appendix A |
| 618 | */ | 649 | */ |
| 619 | int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state) | 650 | int dccp_ackpkts_add(struct dccp_ackpkts *ap, const struct sock *sk, |
| 651 | u64 ackno, u8 state) | ||
| 620 | { | 652 | { |
| 621 | /* | 653 | /* |
| 622 | * Check at the right places if the buffer is full, if it is, tell the | 654 | * Check at the right places if the buffer is full, if it is, tell the |
| @@ -697,7 +729,7 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state) | |||
| 697 | } | 729 | } |
| 698 | 730 | ||
| 699 | ap->dccpap_buf_ackno = ackno; | 731 | ap->dccpap_buf_ackno = ackno; |
| 700 | do_gettimeofday(&ap->dccpap_time); | 732 | dccp_timestamp(sk, &ap->dccpap_time); |
| 701 | out: | 733 | out: |
| 702 | dccp_pr_debug(""); | 734 | dccp_pr_debug(""); |
| 703 | dccp_ackpkts_print(ap); | 735 | dccp_ackpkts_print(ap); |
diff --git a/net/dccp/output.c b/net/dccp/output.c index 28de157a4326..ea6d0e91e511 100644 --- a/net/dccp/output.c +++ b/net/dccp/output.c | |||
| @@ -522,7 +522,4 @@ void dccp_send_close(struct sock *sk, const int active) | |||
| 522 | dccp_transmit_skb(sk, skb_clone(skb, prio)); | 522 | dccp_transmit_skb(sk, skb_clone(skb, prio)); |
| 523 | } else | 523 | } else |
| 524 | dccp_transmit_skb(sk, skb); | 524 | dccp_transmit_skb(sk, skb); |
| 525 | |||
| 526 | ccid_hc_rx_exit(dp->dccps_hc_rx_ccid, sk); | ||
| 527 | ccid_hc_tx_exit(dp->dccps_hc_tx_ccid, sk); | ||
| 528 | } | 525 | } |
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index 2c915f305be3..3407f190afe8 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c | |||
| @@ -117,8 +117,7 @@ static struct dn_rt_hash_bucket *dn_rt_hash_table; | |||
| 117 | static unsigned dn_rt_hash_mask; | 117 | static unsigned dn_rt_hash_mask; |
| 118 | 118 | ||
| 119 | static struct timer_list dn_route_timer; | 119 | static struct timer_list dn_route_timer; |
| 120 | static struct timer_list dn_rt_flush_timer = | 120 | static DEFINE_TIMER(dn_rt_flush_timer, dn_run_flush, 0, 0); |
| 121 | TIMER_INITIALIZER(dn_run_flush, 0, 0); | ||
| 122 | int decnet_dst_gc_interval = 2; | 121 | int decnet_dst_gc_interval = 2; |
| 123 | 122 | ||
| 124 | static struct dst_ops dn_dst_ops = { | 123 | static struct dst_ops dn_dst_ops = { |
diff --git a/net/ieee80211/Kconfig b/net/ieee80211/Kconfig index 58ed4319e693..91b16fbf91f0 100644 --- a/net/ieee80211/Kconfig +++ b/net/ieee80211/Kconfig | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | config IEEE80211 | 1 | config IEEE80211 |
| 2 | tristate "Generic IEEE 802.11 Networking Stack" | 2 | tristate "Generic IEEE 802.11 Networking Stack" |
| 3 | select NET_RADIO | ||
| 4 | ---help--- | 3 | ---help--- |
| 5 | This option enables the hardware independent IEEE 802.11 | 4 | This option enables the hardware independent IEEE 802.11 |
| 6 | networking stack. | 5 | networking stack. |
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index bf147f8db399..a9d84f93442c 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
| @@ -1248,11 +1248,6 @@ module_init(inet_init); | |||
| 1248 | /* ------------------------------------------------------------------------ */ | 1248 | /* ------------------------------------------------------------------------ */ |
| 1249 | 1249 | ||
| 1250 | #ifdef CONFIG_PROC_FS | 1250 | #ifdef CONFIG_PROC_FS |
| 1251 | #ifdef CONFIG_IP_FIB_TRIE | ||
| 1252 | extern int fib_stat_proc_init(void); | ||
| 1253 | extern void fib_stat_proc_exit(void); | ||
| 1254 | #endif | ||
| 1255 | |||
| 1256 | static int __init ipv4_proc_init(void) | 1251 | static int __init ipv4_proc_init(void) |
| 1257 | { | 1252 | { |
| 1258 | int rc = 0; | 1253 | int rc = 0; |
| @@ -1265,19 +1260,11 @@ static int __init ipv4_proc_init(void) | |||
| 1265 | goto out_udp; | 1260 | goto out_udp; |
| 1266 | if (fib_proc_init()) | 1261 | if (fib_proc_init()) |
| 1267 | goto out_fib; | 1262 | goto out_fib; |
| 1268 | #ifdef CONFIG_IP_FIB_TRIE | ||
| 1269 | if (fib_stat_proc_init()) | ||
| 1270 | goto out_fib_stat; | ||
| 1271 | #endif | ||
| 1272 | if (ip_misc_proc_init()) | 1263 | if (ip_misc_proc_init()) |
| 1273 | goto out_misc; | 1264 | goto out_misc; |
| 1274 | out: | 1265 | out: |
| 1275 | return rc; | 1266 | return rc; |
| 1276 | out_misc: | 1267 | out_misc: |
| 1277 | #ifdef CONFIG_IP_FIB_TRIE | ||
| 1278 | fib_stat_proc_exit(); | ||
| 1279 | out_fib_stat: | ||
| 1280 | #endif | ||
| 1281 | fib_proc_exit(); | 1268 | fib_proc_exit(); |
| 1282 | out_fib: | 1269 | out_fib: |
| 1283 | udp4_proc_exit(); | 1270 | udp4_proc_exit(); |
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index b2dea4e5da77..1b63b4824164 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
| @@ -43,7 +43,7 @@ | |||
| 43 | * 2 of the License, or (at your option) any later version. | 43 | * 2 of the License, or (at your option) any later version. |
| 44 | */ | 44 | */ |
| 45 | 45 | ||
| 46 | #define VERSION "0.402" | 46 | #define VERSION "0.403" |
| 47 | 47 | ||
| 48 | #include <linux/config.h> | 48 | #include <linux/config.h> |
| 49 | #include <asm/uaccess.h> | 49 | #include <asm/uaccess.h> |
| @@ -164,7 +164,6 @@ static struct node *resize(struct trie *t, struct tnode *tn); | |||
| 164 | static struct tnode *inflate(struct trie *t, struct tnode *tn); | 164 | static struct tnode *inflate(struct trie *t, struct tnode *tn); |
| 165 | static struct tnode *halve(struct trie *t, struct tnode *tn); | 165 | static struct tnode *halve(struct trie *t, struct tnode *tn); |
| 166 | static void tnode_free(struct tnode *tn); | 166 | static void tnode_free(struct tnode *tn); |
| 167 | static void trie_dump_seq(struct seq_file *seq, struct trie *t); | ||
| 168 | 167 | ||
| 169 | static kmem_cache_t *fn_alias_kmem __read_mostly; | 168 | static kmem_cache_t *fn_alias_kmem __read_mostly; |
| 170 | static struct trie *trie_local = NULL, *trie_main = NULL; | 169 | static struct trie *trie_local = NULL, *trie_main = NULL; |
| @@ -1971,558 +1970,525 @@ struct fib_table * __init fib_hash_init(int id) | |||
| 1971 | return tb; | 1970 | return tb; |
| 1972 | } | 1971 | } |
| 1973 | 1972 | ||
| 1974 | /* Trie dump functions */ | 1973 | #ifdef CONFIG_PROC_FS |
| 1974 | /* Depth first Trie walk iterator */ | ||
| 1975 | struct fib_trie_iter { | ||
| 1976 | struct tnode *tnode; | ||
| 1977 | struct trie *trie; | ||
| 1978 | unsigned index; | ||
| 1979 | unsigned depth; | ||
| 1980 | }; | ||
| 1975 | 1981 | ||
| 1976 | static void putspace_seq(struct seq_file *seq, int n) | 1982 | static struct node *fib_trie_get_next(struct fib_trie_iter *iter) |
| 1977 | { | 1983 | { |
| 1978 | while (n--) | 1984 | struct tnode *tn = iter->tnode; |
| 1979 | seq_printf(seq, " "); | 1985 | unsigned cindex = iter->index; |
| 1980 | } | 1986 | struct tnode *p; |
| 1981 | 1987 | ||
| 1982 | static void printbin_seq(struct seq_file *seq, unsigned int v, int bits) | 1988 | pr_debug("get_next iter={node=%p index=%d depth=%d}\n", |
| 1983 | { | 1989 | iter->tnode, iter->index, iter->depth); |
| 1984 | while (bits--) | 1990 | rescan: |
| 1985 | seq_printf(seq, "%s", (v & (1<<bits))?"1":"0"); | 1991 | while (cindex < (1<<tn->bits)) { |
| 1986 | } | 1992 | struct node *n = tnode_get_child(tn, cindex); |
| 1987 | 1993 | ||
| 1988 | static void printnode_seq(struct seq_file *seq, int indent, struct node *n, | 1994 | if (n) { |
| 1989 | int pend, int cindex, int bits) | 1995 | if (IS_LEAF(n)) { |
| 1990 | { | 1996 | iter->tnode = tn; |
| 1991 | putspace_seq(seq, indent); | 1997 | iter->index = cindex + 1; |
| 1992 | if (IS_LEAF(n)) | 1998 | } else { |
| 1993 | seq_printf(seq, "|"); | 1999 | /* push down one level */ |
| 1994 | else | 2000 | iter->tnode = (struct tnode *) n; |
| 1995 | seq_printf(seq, "+"); | 2001 | iter->index = 0; |
| 1996 | if (bits) { | 2002 | ++iter->depth; |
| 1997 | seq_printf(seq, "%d/", cindex); | 2003 | } |
| 1998 | printbin_seq(seq, cindex, bits); | 2004 | return n; |
| 1999 | seq_printf(seq, ": "); | 2005 | } |
| 2000 | } else | ||
| 2001 | seq_printf(seq, "<root>: "); | ||
| 2002 | seq_printf(seq, "%s:%p ", IS_LEAF(n)?"Leaf":"Internal node", n); | ||
| 2003 | 2006 | ||
| 2004 | if (IS_LEAF(n)) { | 2007 | ++cindex; |
| 2005 | struct leaf *l = (struct leaf *)n; | 2008 | } |
| 2006 | struct fib_alias *fa; | ||
| 2007 | int i; | ||
| 2008 | 2009 | ||
| 2009 | seq_printf(seq, "key=%d.%d.%d.%d\n", | 2010 | /* Current node exhausted, pop back up */ |
| 2010 | n->key >> 24, (n->key >> 16) % 256, (n->key >> 8) % 256, n->key % 256); | 2011 | p = NODE_PARENT(tn); |
| 2011 | 2012 | if (p) { | |
| 2012 | for (i = 32; i >= 0; i--) | 2013 | cindex = tkey_extract_bits(tn->key, p->pos, p->bits)+1; |
| 2013 | if (find_leaf_info(&l->list, i)) { | 2014 | tn = p; |
| 2014 | struct list_head *fa_head = get_fa_head(l, i); | 2015 | --iter->depth; |
| 2015 | 2016 | goto rescan; | |
| 2016 | if (!fa_head) | ||
| 2017 | continue; | ||
| 2018 | |||
| 2019 | if (list_empty(fa_head)) | ||
| 2020 | continue; | ||
| 2021 | |||
| 2022 | putspace_seq(seq, indent+2); | ||
| 2023 | seq_printf(seq, "{/%d...dumping}\n", i); | ||
| 2024 | |||
| 2025 | list_for_each_entry_rcu(fa, fa_head, fa_list) { | ||
| 2026 | putspace_seq(seq, indent+2); | ||
| 2027 | if (fa->fa_info == NULL) { | ||
| 2028 | seq_printf(seq, "Error fa_info=NULL\n"); | ||
| 2029 | continue; | ||
| 2030 | } | ||
| 2031 | if (fa->fa_info->fib_nh == NULL) { | ||
| 2032 | seq_printf(seq, "Error _fib_nh=NULL\n"); | ||
| 2033 | continue; | ||
| 2034 | } | ||
| 2035 | |||
| 2036 | seq_printf(seq, "{type=%d scope=%d TOS=%d}\n", | ||
| 2037 | fa->fa_type, | ||
| 2038 | fa->fa_scope, | ||
| 2039 | fa->fa_tos); | ||
| 2040 | } | ||
| 2041 | } | ||
| 2042 | } else { | ||
| 2043 | struct tnode *tn = (struct tnode *)n; | ||
| 2044 | int plen = ((struct tnode *)n)->pos; | ||
| 2045 | t_key prf = MASK_PFX(n->key, plen); | ||
| 2046 | |||
| 2047 | seq_printf(seq, "key=%d.%d.%d.%d/%d\n", | ||
| 2048 | prf >> 24, (prf >> 16) % 256, (prf >> 8) % 256, prf % 256, plen); | ||
| 2049 | |||
| 2050 | putspace_seq(seq, indent); seq_printf(seq, "| "); | ||
| 2051 | seq_printf(seq, "{key prefix=%08x/", tn->key & TKEY_GET_MASK(0, tn->pos)); | ||
| 2052 | printbin_seq(seq, tkey_extract_bits(tn->key, 0, tn->pos), tn->pos); | ||
| 2053 | seq_printf(seq, "}\n"); | ||
| 2054 | putspace_seq(seq, indent); seq_printf(seq, "| "); | ||
| 2055 | seq_printf(seq, "{pos=%d", tn->pos); | ||
| 2056 | seq_printf(seq, " (skip=%d bits)", tn->pos - pend); | ||
| 2057 | seq_printf(seq, " bits=%d (%u children)}\n", tn->bits, (1 << tn->bits)); | ||
| 2058 | putspace_seq(seq, indent); seq_printf(seq, "| "); | ||
| 2059 | seq_printf(seq, "{empty=%d full=%d}\n", tn->empty_children, tn->full_children); | ||
| 2060 | } | 2017 | } |
| 2018 | |||
| 2019 | /* got root? */ | ||
| 2020 | return NULL; | ||
| 2061 | } | 2021 | } |
| 2062 | 2022 | ||
| 2063 | static void trie_dump_seq(struct seq_file *seq, struct trie *t) | 2023 | static struct node *fib_trie_get_first(struct fib_trie_iter *iter, |
| 2024 | struct trie *t) | ||
| 2064 | { | 2025 | { |
| 2065 | struct node *n; | 2026 | struct node *n = rcu_dereference(t->trie); |
| 2066 | int cindex = 0; | ||
| 2067 | int indent = 1; | ||
| 2068 | int pend = 0; | ||
| 2069 | int depth = 0; | ||
| 2070 | struct tnode *tn; | ||
| 2071 | |||
| 2072 | rcu_read_lock(); | ||
| 2073 | n = rcu_dereference(t->trie); | ||
| 2074 | seq_printf(seq, "------ trie_dump of t=%p ------\n", t); | ||
| 2075 | 2027 | ||
| 2076 | if (!n) { | 2028 | if (n && IS_TNODE(n)) { |
| 2077 | seq_printf(seq, "------ trie is empty\n"); | 2029 | iter->tnode = (struct tnode *) n; |
| 2078 | 2030 | iter->trie = t; | |
| 2079 | rcu_read_unlock(); | 2031 | iter->index = 0; |
| 2080 | return; | 2032 | iter->depth = 0; |
| 2033 | return n; | ||
| 2081 | } | 2034 | } |
| 2035 | return NULL; | ||
| 2036 | } | ||
| 2082 | 2037 | ||
| 2083 | printnode_seq(seq, indent, n, pend, cindex, 0); | 2038 | static void trie_collect_stats(struct trie *t, struct trie_stat *s) |
| 2084 | 2039 | { | |
| 2085 | if (!IS_TNODE(n)) { | 2040 | struct node *n; |
| 2086 | rcu_read_unlock(); | 2041 | struct fib_trie_iter iter; |
| 2087 | return; | ||
| 2088 | } | ||
| 2089 | |||
| 2090 | tn = (struct tnode *)n; | ||
| 2091 | pend = tn->pos+tn->bits; | ||
| 2092 | putspace_seq(seq, indent); seq_printf(seq, "\\--\n"); | ||
| 2093 | indent += 3; | ||
| 2094 | depth++; | ||
| 2095 | |||
| 2096 | while (tn && cindex < (1 << tn->bits)) { | ||
| 2097 | struct node *child = rcu_dereference(tn->child[cindex]); | ||
| 2098 | if (!child) | ||
| 2099 | cindex++; | ||
| 2100 | else { | ||
| 2101 | /* Got a child */ | ||
| 2102 | printnode_seq(seq, indent, child, pend, | ||
| 2103 | cindex, tn->bits); | ||
| 2104 | |||
| 2105 | if (IS_LEAF(child)) | ||
| 2106 | cindex++; | ||
| 2107 | |||
| 2108 | else { | ||
| 2109 | /* | ||
| 2110 | * New tnode. Decend one level | ||
| 2111 | */ | ||
| 2112 | |||
| 2113 | depth++; | ||
| 2114 | n = child; | ||
| 2115 | tn = (struct tnode *)n; | ||
| 2116 | pend = tn->pos+tn->bits; | ||
| 2117 | putspace_seq(seq, indent); | ||
| 2118 | seq_printf(seq, "\\--\n"); | ||
| 2119 | indent += 3; | ||
| 2120 | cindex = 0; | ||
| 2121 | } | ||
| 2122 | } | ||
| 2123 | |||
| 2124 | /* | ||
| 2125 | * Test if we are done | ||
| 2126 | */ | ||
| 2127 | |||
| 2128 | while (cindex >= (1 << tn->bits)) { | ||
| 2129 | /* | ||
| 2130 | * Move upwards and test for root | ||
| 2131 | * pop off all traversed nodes | ||
| 2132 | */ | ||
| 2133 | 2042 | ||
| 2134 | if (NODE_PARENT(tn) == NULL) { | 2043 | memset(s, 0, sizeof(*s)); |
| 2135 | tn = NULL; | ||
| 2136 | break; | ||
| 2137 | } | ||
| 2138 | 2044 | ||
| 2139 | cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits); | 2045 | rcu_read_lock(); |
| 2140 | cindex++; | 2046 | for (n = fib_trie_get_first(&iter, t); n; |
| 2141 | tn = NODE_PARENT(tn); | 2047 | n = fib_trie_get_next(&iter)) { |
| 2142 | pend = tn->pos + tn->bits; | 2048 | if (IS_LEAF(n)) { |
| 2143 | indent -= 3; | 2049 | s->leaves++; |
| 2144 | depth--; | 2050 | s->totdepth += iter.depth; |
| 2051 | if (iter.depth > s->maxdepth) | ||
| 2052 | s->maxdepth = iter.depth; | ||
| 2053 | } else { | ||
| 2054 | const struct tnode *tn = (const struct tnode *) n; | ||
| 2055 | int i; | ||
| 2056 | |||
| 2057 | s->tnodes++; | ||
| 2058 | s->nodesizes[tn->bits]++; | ||
| 2059 | for (i = 0; i < (1<<tn->bits); i++) | ||
| 2060 | if (!tn->child[i]) | ||
| 2061 | s->nullpointers++; | ||
| 2145 | } | 2062 | } |
| 2146 | } | 2063 | } |
| 2147 | rcu_read_unlock(); | 2064 | rcu_read_unlock(); |
| 2148 | } | 2065 | } |
| 2149 | 2066 | ||
| 2150 | static struct trie_stat *trie_stat_new(void) | 2067 | /* |
| 2068 | * This outputs /proc/net/fib_triestats | ||
| 2069 | */ | ||
| 2070 | static void trie_show_stats(struct seq_file *seq, struct trie_stat *stat) | ||
| 2151 | { | 2071 | { |
| 2152 | struct trie_stat *s; | 2072 | unsigned i, max, pointers, bytes, avdepth; |
| 2153 | int i; | ||
| 2154 | 2073 | ||
| 2155 | s = kmalloc(sizeof(struct trie_stat), GFP_KERNEL); | 2074 | if (stat->leaves) |
| 2156 | if (!s) | 2075 | avdepth = stat->totdepth*100 / stat->leaves; |
| 2157 | return NULL; | 2076 | else |
| 2077 | avdepth = 0; | ||
| 2158 | 2078 | ||
| 2159 | s->totdepth = 0; | 2079 | seq_printf(seq, "\tAver depth: %d.%02d\n", avdepth / 100, avdepth % 100 ); |
| 2160 | s->maxdepth = 0; | 2080 | seq_printf(seq, "\tMax depth: %u\n", stat->maxdepth); |
| 2161 | s->tnodes = 0; | ||
| 2162 | s->leaves = 0; | ||
| 2163 | s->nullpointers = 0; | ||
| 2164 | 2081 | ||
| 2165 | for (i = 0; i < MAX_CHILDS; i++) | 2082 | seq_printf(seq, "\tLeaves: %u\n", stat->leaves); |
| 2166 | s->nodesizes[i] = 0; | ||
| 2167 | 2083 | ||
| 2168 | return s; | 2084 | bytes = sizeof(struct leaf) * stat->leaves; |
| 2169 | } | 2085 | seq_printf(seq, "\tInternal nodes: %d\n\t", stat->tnodes); |
| 2086 | bytes += sizeof(struct tnode) * stat->tnodes; | ||
| 2170 | 2087 | ||
| 2171 | static struct trie_stat *trie_collect_stats(struct trie *t) | 2088 | max = MAX_CHILDS-1; |
| 2172 | { | 2089 | while (max >= 0 && stat->nodesizes[max] == 0) |
| 2173 | struct node *n; | 2090 | max--; |
| 2174 | struct trie_stat *s = trie_stat_new(); | ||
| 2175 | int cindex = 0; | ||
| 2176 | int pend = 0; | ||
| 2177 | int depth = 0; | ||
| 2178 | 2091 | ||
| 2179 | if (!s) | 2092 | pointers = 0; |
| 2180 | return NULL; | 2093 | for (i = 1; i <= max; i++) |
| 2094 | if (stat->nodesizes[i] != 0) { | ||
| 2095 | seq_printf(seq, " %d: %d", i, stat->nodesizes[i]); | ||
| 2096 | pointers += (1<<i) * stat->nodesizes[i]; | ||
| 2097 | } | ||
| 2098 | seq_putc(seq, '\n'); | ||
| 2099 | seq_printf(seq, "\tPointers: %d\n", pointers); | ||
| 2181 | 2100 | ||
| 2182 | rcu_read_lock(); | 2101 | bytes += sizeof(struct node *) * pointers; |
| 2183 | n = rcu_dereference(t->trie); | 2102 | seq_printf(seq, "Null ptrs: %d\n", stat->nullpointers); |
| 2103 | seq_printf(seq, "Total size: %d kB\n", (bytes + 1023) / 1024); | ||
| 2184 | 2104 | ||
| 2185 | if (!n) | 2105 | #ifdef CONFIG_IP_FIB_TRIE_STATS |
| 2186 | return s; | 2106 | seq_printf(seq, "Counters:\n---------\n"); |
| 2107 | seq_printf(seq,"gets = %d\n", t->stats.gets); | ||
| 2108 | seq_printf(seq,"backtracks = %d\n", t->stats.backtrack); | ||
| 2109 | seq_printf(seq,"semantic match passed = %d\n", t->stats.semantic_match_passed); | ||
| 2110 | seq_printf(seq,"semantic match miss = %d\n", t->stats.semantic_match_miss); | ||
| 2111 | seq_printf(seq,"null node hit= %d\n", t->stats.null_node_hit); | ||
| 2112 | seq_printf(seq,"skipped node resize = %d\n", t->stats.resize_node_skipped); | ||
| 2113 | #ifdef CLEAR_STATS | ||
| 2114 | memset(&(t->stats), 0, sizeof(t->stats)); | ||
| 2115 | #endif | ||
| 2116 | #endif /* CONFIG_IP_FIB_TRIE_STATS */ | ||
| 2117 | } | ||
| 2187 | 2118 | ||
| 2188 | if (IS_TNODE(n)) { | 2119 | static int fib_triestat_seq_show(struct seq_file *seq, void *v) |
| 2189 | struct tnode *tn = (struct tnode *)n; | 2120 | { |
| 2190 | pend = tn->pos+tn->bits; | 2121 | struct trie_stat *stat; |
| 2191 | s->nodesizes[tn->bits]++; | ||
| 2192 | depth++; | ||
| 2193 | |||
| 2194 | while (tn && cindex < (1 << tn->bits)) { | ||
| 2195 | struct node *ch = rcu_dereference(tn->child[cindex]); | ||
| 2196 | if (ch) { | ||
| 2197 | |||
| 2198 | /* Got a child */ | ||
| 2199 | |||
| 2200 | if (IS_LEAF(tn->child[cindex])) { | ||
| 2201 | cindex++; | ||
| 2202 | |||
| 2203 | /* stats */ | ||
| 2204 | if (depth > s->maxdepth) | ||
| 2205 | s->maxdepth = depth; | ||
| 2206 | s->totdepth += depth; | ||
| 2207 | s->leaves++; | ||
| 2208 | } else { | ||
| 2209 | /* | ||
| 2210 | * New tnode. Decend one level | ||
| 2211 | */ | ||
| 2212 | |||
| 2213 | s->tnodes++; | ||
| 2214 | s->nodesizes[tn->bits]++; | ||
| 2215 | depth++; | ||
| 2216 | |||
| 2217 | n = ch; | ||
| 2218 | tn = (struct tnode *)n; | ||
| 2219 | pend = tn->pos+tn->bits; | ||
| 2220 | |||
| 2221 | cindex = 0; | ||
| 2222 | } | ||
| 2223 | } else { | ||
| 2224 | cindex++; | ||
| 2225 | s->nullpointers++; | ||
| 2226 | } | ||
| 2227 | 2122 | ||
| 2228 | /* | 2123 | stat = kmalloc(sizeof(*stat), GFP_KERNEL); |
| 2229 | * Test if we are done | 2124 | if (!stat) |
| 2230 | */ | 2125 | return -ENOMEM; |
| 2231 | 2126 | ||
| 2232 | while (cindex >= (1 << tn->bits)) { | 2127 | seq_printf(seq, "Basic info: size of leaf: %Zd bytes, size of tnode: %Zd bytes.\n", |
| 2233 | /* | 2128 | sizeof(struct leaf), sizeof(struct tnode)); |
| 2234 | * Move upwards and test for root | ||
| 2235 | * pop off all traversed nodes | ||
| 2236 | */ | ||
| 2237 | 2129 | ||
| 2238 | if (NODE_PARENT(tn) == NULL) { | 2130 | if (trie_local) { |
| 2239 | tn = NULL; | 2131 | seq_printf(seq, "Local:\n"); |
| 2240 | n = NULL; | 2132 | trie_collect_stats(trie_local, stat); |
| 2241 | break; | 2133 | trie_show_stats(seq, stat); |
| 2242 | } | 2134 | } |
| 2243 | 2135 | ||
| 2244 | cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits); | 2136 | if (trie_main) { |
| 2245 | tn = NODE_PARENT(tn); | 2137 | seq_printf(seq, "Main:\n"); |
| 2246 | cindex++; | 2138 | trie_collect_stats(trie_main, stat); |
| 2247 | n = (struct node *)tn; | 2139 | trie_show_stats(seq, stat); |
| 2248 | pend = tn->pos+tn->bits; | ||
| 2249 | depth--; | ||
| 2250 | } | ||
| 2251 | } | ||
| 2252 | } | 2140 | } |
| 2141 | kfree(stat); | ||
| 2253 | 2142 | ||
| 2254 | rcu_read_unlock(); | 2143 | return 0; |
| 2255 | return s; | ||
| 2256 | } | 2144 | } |
| 2257 | 2145 | ||
| 2258 | #ifdef CONFIG_PROC_FS | 2146 | static int fib_triestat_seq_open(struct inode *inode, struct file *file) |
| 2259 | |||
| 2260 | static struct fib_alias *fib_triestat_get_first(struct seq_file *seq) | ||
| 2261 | { | 2147 | { |
| 2262 | return NULL; | 2148 | return single_open(file, fib_triestat_seq_show, NULL); |
| 2263 | } | 2149 | } |
| 2264 | 2150 | ||
| 2265 | static struct fib_alias *fib_triestat_get_next(struct seq_file *seq) | 2151 | static struct file_operations fib_triestat_fops = { |
| 2152 | .owner = THIS_MODULE, | ||
| 2153 | .open = fib_triestat_seq_open, | ||
| 2154 | .read = seq_read, | ||
| 2155 | .llseek = seq_lseek, | ||
| 2156 | .release = single_release, | ||
| 2157 | }; | ||
| 2158 | |||
| 2159 | static struct node *fib_trie_get_idx(struct fib_trie_iter *iter, | ||
| 2160 | loff_t pos) | ||
| 2266 | { | 2161 | { |
| 2162 | loff_t idx = 0; | ||
| 2163 | struct node *n; | ||
| 2164 | |||
| 2165 | for (n = fib_trie_get_first(iter, trie_local); | ||
| 2166 | n; ++idx, n = fib_trie_get_next(iter)) { | ||
| 2167 | if (pos == idx) | ||
| 2168 | return n; | ||
| 2169 | } | ||
| 2170 | |||
| 2171 | for (n = fib_trie_get_first(iter, trie_main); | ||
| 2172 | n; ++idx, n = fib_trie_get_next(iter)) { | ||
| 2173 | if (pos == idx) | ||
| 2174 | return n; | ||
| 2175 | } | ||
| 2267 | return NULL; | 2176 | return NULL; |
| 2268 | } | 2177 | } |
| 2269 | 2178 | ||
| 2270 | static void *fib_triestat_seq_start(struct seq_file *seq, loff_t *pos) | 2179 | static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos) |
| 2271 | { | 2180 | { |
| 2272 | if (!ip_fib_main_table) | 2181 | rcu_read_lock(); |
| 2273 | return NULL; | 2182 | if (*pos == 0) |
| 2274 | |||
| 2275 | if (*pos) | ||
| 2276 | return fib_triestat_get_next(seq); | ||
| 2277 | else | ||
| 2278 | return SEQ_START_TOKEN; | 2183 | return SEQ_START_TOKEN; |
| 2184 | return fib_trie_get_idx(seq->private, *pos - 1); | ||
| 2279 | } | 2185 | } |
| 2280 | 2186 | ||
| 2281 | static void *fib_triestat_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 2187 | static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
| 2282 | { | 2188 | { |
| 2189 | struct fib_trie_iter *iter = seq->private; | ||
| 2190 | void *l = v; | ||
| 2191 | |||
| 2283 | ++*pos; | 2192 | ++*pos; |
| 2284 | if (v == SEQ_START_TOKEN) | 2193 | if (v == SEQ_START_TOKEN) |
| 2285 | return fib_triestat_get_first(seq); | 2194 | return fib_trie_get_idx(iter, 0); |
| 2286 | else | ||
| 2287 | return fib_triestat_get_next(seq); | ||
| 2288 | } | ||
| 2289 | 2195 | ||
| 2290 | static void fib_triestat_seq_stop(struct seq_file *seq, void *v) | 2196 | v = fib_trie_get_next(iter); |
| 2291 | { | 2197 | BUG_ON(v == l); |
| 2198 | if (v) | ||
| 2199 | return v; | ||
| 2292 | 2200 | ||
| 2293 | } | 2201 | /* continue scan in next trie */ |
| 2202 | if (iter->trie == trie_local) | ||
| 2203 | return fib_trie_get_first(iter, trie_main); | ||
| 2294 | 2204 | ||
| 2295 | /* | 2205 | return NULL; |
| 2296 | * This outputs /proc/net/fib_triestats | 2206 | } |
| 2297 | * | ||
| 2298 | * It always works in backward compatibility mode. | ||
| 2299 | * The format of the file is not supposed to be changed. | ||
| 2300 | */ | ||
| 2301 | 2207 | ||
| 2302 | static void collect_and_show(struct trie *t, struct seq_file *seq) | 2208 | static void fib_trie_seq_stop(struct seq_file *seq, void *v) |
| 2303 | { | 2209 | { |
| 2304 | int bytes = 0; /* How many bytes are used, a ref is 4 bytes */ | 2210 | rcu_read_unlock(); |
| 2305 | int i, max, pointers; | 2211 | } |
| 2306 | struct trie_stat *stat; | ||
| 2307 | int avdepth; | ||
| 2308 | |||
| 2309 | stat = trie_collect_stats(t); | ||
| 2310 | |||
| 2311 | bytes = 0; | ||
| 2312 | seq_printf(seq, "trie=%p\n", t); | ||
| 2313 | |||
| 2314 | if (stat) { | ||
| 2315 | if (stat->leaves) | ||
| 2316 | avdepth = stat->totdepth*100 / stat->leaves; | ||
| 2317 | else | ||
| 2318 | avdepth = 0; | ||
| 2319 | seq_printf(seq, "Aver depth: %d.%02d\n", avdepth / 100, avdepth % 100); | ||
| 2320 | seq_printf(seq, "Max depth: %4d\n", stat->maxdepth); | ||
| 2321 | 2212 | ||
| 2322 | seq_printf(seq, "Leaves: %d\n", stat->leaves); | 2213 | static void seq_indent(struct seq_file *seq, int n) |
| 2323 | bytes += sizeof(struct leaf) * stat->leaves; | 2214 | { |
| 2324 | seq_printf(seq, "Internal nodes: %d\n", stat->tnodes); | 2215 | while (n-- > 0) seq_puts(seq, " "); |
| 2325 | bytes += sizeof(struct tnode) * stat->tnodes; | 2216 | } |
| 2326 | 2217 | ||
| 2327 | max = MAX_CHILDS-1; | 2218 | static inline const char *rtn_scope(enum rt_scope_t s) |
| 2219 | { | ||
| 2220 | static char buf[32]; | ||
| 2328 | 2221 | ||
| 2329 | while (max >= 0 && stat->nodesizes[max] == 0) | 2222 | switch(s) { |
| 2330 | max--; | 2223 | case RT_SCOPE_UNIVERSE: return "universe"; |
| 2331 | pointers = 0; | 2224 | case RT_SCOPE_SITE: return "site"; |
| 2225 | case RT_SCOPE_LINK: return "link"; | ||
| 2226 | case RT_SCOPE_HOST: return "host"; | ||
| 2227 | case RT_SCOPE_NOWHERE: return "nowhere"; | ||
| 2228 | default: | ||
| 2229 | snprintf(buf, sizeof(buf), "scope=%d", s); | ||
| 2230 | return buf; | ||
| 2231 | } | ||
| 2232 | } | ||
| 2332 | 2233 | ||
| 2333 | for (i = 1; i <= max; i++) | 2234 | static const char *rtn_type_names[__RTN_MAX] = { |
| 2334 | if (stat->nodesizes[i] != 0) { | 2235 | [RTN_UNSPEC] = "UNSPEC", |
| 2335 | seq_printf(seq, " %d: %d", i, stat->nodesizes[i]); | 2236 | [RTN_UNICAST] = "UNICAST", |
| 2336 | pointers += (1<<i) * stat->nodesizes[i]; | 2237 | [RTN_LOCAL] = "LOCAL", |
| 2337 | } | 2238 | [RTN_BROADCAST] = "BROADCAST", |
| 2338 | seq_printf(seq, "\n"); | 2239 | [RTN_ANYCAST] = "ANYCAST", |
| 2339 | seq_printf(seq, "Pointers: %d\n", pointers); | 2240 | [RTN_MULTICAST] = "MULTICAST", |
| 2340 | bytes += sizeof(struct node *) * pointers; | 2241 | [RTN_BLACKHOLE] = "BLACKHOLE", |
| 2341 | seq_printf(seq, "Null ptrs: %d\n", stat->nullpointers); | 2242 | [RTN_UNREACHABLE] = "UNREACHABLE", |
| 2342 | seq_printf(seq, "Total size: %d kB\n", bytes / 1024); | 2243 | [RTN_PROHIBIT] = "PROHIBIT", |
| 2244 | [RTN_THROW] = "THROW", | ||
| 2245 | [RTN_NAT] = "NAT", | ||
| 2246 | [RTN_XRESOLVE] = "XRESOLVE", | ||
| 2247 | }; | ||
| 2343 | 2248 | ||
| 2344 | kfree(stat); | 2249 | static inline const char *rtn_type(unsigned t) |
| 2345 | } | 2250 | { |
| 2251 | static char buf[32]; | ||
| 2346 | 2252 | ||
| 2347 | #ifdef CONFIG_IP_FIB_TRIE_STATS | 2253 | if (t < __RTN_MAX && rtn_type_names[t]) |
| 2348 | seq_printf(seq, "Counters:\n---------\n"); | 2254 | return rtn_type_names[t]; |
| 2349 | seq_printf(seq,"gets = %d\n", t->stats.gets); | 2255 | snprintf(buf, sizeof(buf), "type %d", t); |
| 2350 | seq_printf(seq,"backtracks = %d\n", t->stats.backtrack); | 2256 | return buf; |
| 2351 | seq_printf(seq,"semantic match passed = %d\n", t->stats.semantic_match_passed); | ||
| 2352 | seq_printf(seq,"semantic match miss = %d\n", t->stats.semantic_match_miss); | ||
| 2353 | seq_printf(seq,"null node hit= %d\n", t->stats.null_node_hit); | ||
| 2354 | seq_printf(seq,"skipped node resize = %d\n", t->stats.resize_node_skipped); | ||
| 2355 | #ifdef CLEAR_STATS | ||
| 2356 | memset(&(t->stats), 0, sizeof(t->stats)); | ||
| 2357 | #endif | ||
| 2358 | #endif /* CONFIG_IP_FIB_TRIE_STATS */ | ||
| 2359 | } | 2257 | } |
| 2360 | 2258 | ||
| 2361 | static int fib_triestat_seq_show(struct seq_file *seq, void *v) | 2259 | /* Pretty print the trie */ |
| 2260 | static int fib_trie_seq_show(struct seq_file *seq, void *v) | ||
| 2362 | { | 2261 | { |
| 2363 | char bf[128]; | 2262 | const struct fib_trie_iter *iter = seq->private; |
| 2263 | struct node *n = v; | ||
| 2364 | 2264 | ||
| 2365 | if (v == SEQ_START_TOKEN) { | 2265 | if (v == SEQ_START_TOKEN) |
| 2366 | seq_printf(seq, "Basic info: size of leaf: %Zd bytes, size of tnode: %Zd bytes.\n", | 2266 | return 0; |
| 2367 | sizeof(struct leaf), sizeof(struct tnode)); | ||
| 2368 | if (trie_local) | ||
| 2369 | collect_and_show(trie_local, seq); | ||
| 2370 | 2267 | ||
| 2371 | if (trie_main) | 2268 | if (IS_TNODE(n)) { |
| 2372 | collect_and_show(trie_main, seq); | 2269 | struct tnode *tn = (struct tnode *) n; |
| 2373 | } else { | 2270 | t_key prf = ntohl(MASK_PFX(tn->key, tn->pos)); |
| 2374 | snprintf(bf, sizeof(bf), "*\t%08X\t%08X", 200, 400); | ||
| 2375 | 2271 | ||
| 2376 | seq_printf(seq, "%-127s\n", bf); | 2272 | if (!NODE_PARENT(n)) { |
| 2273 | if (iter->trie == trie_local) | ||
| 2274 | seq_puts(seq, "<local>:\n"); | ||
| 2275 | else | ||
| 2276 | seq_puts(seq, "<main>:\n"); | ||
| 2277 | } else { | ||
| 2278 | seq_indent(seq, iter->depth-1); | ||
| 2279 | seq_printf(seq, " +-- %d.%d.%d.%d/%d\n", | ||
| 2280 | NIPQUAD(prf), tn->pos); | ||
| 2281 | } | ||
| 2282 | } else { | ||
| 2283 | struct leaf *l = (struct leaf *) n; | ||
| 2284 | int i; | ||
| 2285 | u32 val = ntohl(l->key); | ||
| 2286 | |||
| 2287 | seq_indent(seq, iter->depth); | ||
| 2288 | seq_printf(seq, " |-- %d.%d.%d.%d\n", NIPQUAD(val)); | ||
| 2289 | for (i = 32; i >= 0; i--) { | ||
| 2290 | struct leaf_info *li = find_leaf_info(&l->list, i); | ||
| 2291 | if (li) { | ||
| 2292 | struct fib_alias *fa; | ||
| 2293 | list_for_each_entry_rcu(fa, &li->falh, fa_list) { | ||
| 2294 | seq_indent(seq, iter->depth+1); | ||
| 2295 | seq_printf(seq, " /%d %s %s", i, | ||
| 2296 | rtn_scope(fa->fa_scope), | ||
| 2297 | rtn_type(fa->fa_type)); | ||
| 2298 | if (fa->fa_tos) | ||
| 2299 | seq_printf(seq, "tos =%d\n", | ||
| 2300 | fa->fa_tos); | ||
| 2301 | seq_putc(seq, '\n'); | ||
| 2302 | } | ||
| 2303 | } | ||
| 2304 | } | ||
| 2377 | } | 2305 | } |
| 2306 | |||
| 2378 | return 0; | 2307 | return 0; |
| 2379 | } | 2308 | } |
| 2380 | 2309 | ||
| 2381 | static struct seq_operations fib_triestat_seq_ops = { | 2310 | static struct seq_operations fib_trie_seq_ops = { |
| 2382 | .start = fib_triestat_seq_start, | 2311 | .start = fib_trie_seq_start, |
| 2383 | .next = fib_triestat_seq_next, | 2312 | .next = fib_trie_seq_next, |
| 2384 | .stop = fib_triestat_seq_stop, | 2313 | .stop = fib_trie_seq_stop, |
| 2385 | .show = fib_triestat_seq_show, | 2314 | .show = fib_trie_seq_show, |
| 2386 | }; | 2315 | }; |
| 2387 | 2316 | ||
| 2388 | static int fib_triestat_seq_open(struct inode *inode, struct file *file) | 2317 | static int fib_trie_seq_open(struct inode *inode, struct file *file) |
| 2389 | { | 2318 | { |
| 2390 | struct seq_file *seq; | 2319 | struct seq_file *seq; |
| 2391 | int rc = -ENOMEM; | 2320 | int rc = -ENOMEM; |
| 2321 | struct fib_trie_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); | ||
| 2392 | 2322 | ||
| 2393 | rc = seq_open(file, &fib_triestat_seq_ops); | 2323 | if (!s) |
| 2324 | goto out; | ||
| 2325 | |||
| 2326 | rc = seq_open(file, &fib_trie_seq_ops); | ||
| 2394 | if (rc) | 2327 | if (rc) |
| 2395 | goto out_kfree; | 2328 | goto out_kfree; |
| 2396 | 2329 | ||
| 2397 | seq = file->private_data; | 2330 | seq = file->private_data; |
| 2331 | seq->private = s; | ||
| 2332 | memset(s, 0, sizeof(*s)); | ||
| 2398 | out: | 2333 | out: |
| 2399 | return rc; | 2334 | return rc; |
| 2400 | out_kfree: | 2335 | out_kfree: |
| 2336 | kfree(s); | ||
| 2401 | goto out; | 2337 | goto out; |
| 2402 | } | 2338 | } |
| 2403 | 2339 | ||
| 2404 | static struct file_operations fib_triestat_seq_fops = { | 2340 | static struct file_operations fib_trie_fops = { |
| 2405 | .owner = THIS_MODULE, | 2341 | .owner = THIS_MODULE, |
| 2406 | .open = fib_triestat_seq_open, | 2342 | .open = fib_trie_seq_open, |
| 2407 | .read = seq_read, | 2343 | .read = seq_read, |
| 2408 | .llseek = seq_lseek, | 2344 | .llseek = seq_lseek, |
| 2409 | .release = seq_release_private, | 2345 | .release = seq_release_private, |
| 2410 | }; | 2346 | }; |
| 2411 | 2347 | ||
| 2412 | int __init fib_stat_proc_init(void) | 2348 | static unsigned fib_flag_trans(int type, u32 mask, const struct fib_info *fi) |
| 2413 | { | ||
| 2414 | if (!proc_net_fops_create("fib_triestat", S_IRUGO, &fib_triestat_seq_fops)) | ||
| 2415 | return -ENOMEM; | ||
| 2416 | return 0; | ||
| 2417 | } | ||
| 2418 | |||
| 2419 | void __init fib_stat_proc_exit(void) | ||
| 2420 | { | 2349 | { |
| 2421 | proc_net_remove("fib_triestat"); | 2350 | static unsigned type2flags[RTN_MAX + 1] = { |
| 2422 | } | 2351 | [7] = RTF_REJECT, [8] = RTF_REJECT, |
| 2352 | }; | ||
| 2353 | unsigned flags = type2flags[type]; | ||
| 2423 | 2354 | ||
| 2424 | static struct fib_alias *fib_trie_get_first(struct seq_file *seq) | 2355 | if (fi && fi->fib_nh->nh_gw) |
| 2425 | { | 2356 | flags |= RTF_GATEWAY; |
| 2426 | return NULL; | 2357 | if (mask == 0xFFFFFFFF) |
| 2358 | flags |= RTF_HOST; | ||
| 2359 | flags |= RTF_UP; | ||
| 2360 | return flags; | ||
| 2427 | } | 2361 | } |
| 2428 | 2362 | ||
| 2429 | static struct fib_alias *fib_trie_get_next(struct seq_file *seq) | 2363 | /* |
| 2364 | * This outputs /proc/net/route. | ||
| 2365 | * The format of the file is not supposed to be changed | ||
| 2366 | * and needs to be same as fib_hash output to avoid breaking | ||
| 2367 | * legacy utilities | ||
| 2368 | */ | ||
| 2369 | static int fib_route_seq_show(struct seq_file *seq, void *v) | ||
| 2430 | { | 2370 | { |
| 2431 | return NULL; | 2371 | struct leaf *l = v; |
| 2432 | } | 2372 | int i; |
| 2373 | char bf[128]; | ||
| 2433 | 2374 | ||
| 2434 | static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos) | 2375 | if (v == SEQ_START_TOKEN) { |
| 2435 | { | 2376 | seq_printf(seq, "%-127s\n", "Iface\tDestination\tGateway " |
| 2436 | if (!ip_fib_main_table) | 2377 | "\tFlags\tRefCnt\tUse\tMetric\tMask\t\tMTU" |
| 2437 | return NULL; | 2378 | "\tWindow\tIRTT"); |
| 2379 | return 0; | ||
| 2380 | } | ||
| 2438 | 2381 | ||
| 2439 | if (*pos) | 2382 | if (IS_TNODE(l)) |
| 2440 | return fib_trie_get_next(seq); | 2383 | return 0; |
| 2441 | else | ||
| 2442 | return SEQ_START_TOKEN; | ||
| 2443 | } | ||
| 2444 | 2384 | ||
| 2445 | static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 2385 | for (i=32; i>=0; i--) { |
| 2446 | { | 2386 | struct leaf_info *li = find_leaf_info(&l->list, i); |
| 2447 | ++*pos; | 2387 | struct fib_alias *fa; |
| 2448 | if (v == SEQ_START_TOKEN) | 2388 | u32 mask, prefix; |
| 2449 | return fib_trie_get_first(seq); | ||
| 2450 | else | ||
| 2451 | return fib_trie_get_next(seq); | ||
| 2452 | 2389 | ||
| 2453 | } | 2390 | if (!li) |
| 2391 | continue; | ||
| 2454 | 2392 | ||
| 2455 | static void fib_trie_seq_stop(struct seq_file *seq, void *v) | 2393 | mask = inet_make_mask(li->plen); |
| 2456 | { | 2394 | prefix = htonl(l->key); |
| 2457 | } | ||
| 2458 | 2395 | ||
| 2459 | /* | 2396 | list_for_each_entry_rcu(fa, &li->falh, fa_list) { |
| 2460 | * This outputs /proc/net/fib_trie. | 2397 | const struct fib_info *fi = rcu_dereference(fa->fa_info); |
| 2461 | * | 2398 | unsigned flags = fib_flag_trans(fa->fa_type, mask, fi); |
| 2462 | * It always works in backward compatibility mode. | ||
| 2463 | * The format of the file is not supposed to be changed. | ||
| 2464 | */ | ||
| 2465 | 2399 | ||
| 2466 | static int fib_trie_seq_show(struct seq_file *seq, void *v) | 2400 | if (fa->fa_type == RTN_BROADCAST |
| 2467 | { | 2401 | || fa->fa_type == RTN_MULTICAST) |
| 2468 | char bf[128]; | 2402 | continue; |
| 2469 | 2403 | ||
| 2470 | if (v == SEQ_START_TOKEN) { | 2404 | if (fi) |
| 2471 | if (trie_local) | 2405 | snprintf(bf, sizeof(bf), |
| 2472 | trie_dump_seq(seq, trie_local); | 2406 | "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u", |
| 2407 | fi->fib_dev ? fi->fib_dev->name : "*", | ||
| 2408 | prefix, | ||
| 2409 | fi->fib_nh->nh_gw, flags, 0, 0, | ||
| 2410 | fi->fib_priority, | ||
| 2411 | mask, | ||
| 2412 | (fi->fib_advmss ? fi->fib_advmss + 40 : 0), | ||
| 2413 | fi->fib_window, | ||
| 2414 | fi->fib_rtt >> 3); | ||
| 2415 | else | ||
| 2416 | snprintf(bf, sizeof(bf), | ||
| 2417 | "*\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u", | ||
| 2418 | prefix, 0, flags, 0, 0, 0, | ||
| 2419 | mask, 0, 0, 0); | ||
| 2473 | 2420 | ||
| 2474 | if (trie_main) | 2421 | seq_printf(seq, "%-127s\n", bf); |
| 2475 | trie_dump_seq(seq, trie_main); | 2422 | } |
| 2476 | } else { | ||
| 2477 | snprintf(bf, sizeof(bf), | ||
| 2478 | "*\t%08X\t%08X", 200, 400); | ||
| 2479 | seq_printf(seq, "%-127s\n", bf); | ||
| 2480 | } | 2423 | } |
| 2481 | 2424 | ||
| 2482 | return 0; | 2425 | return 0; |
| 2483 | } | 2426 | } |
| 2484 | 2427 | ||
| 2485 | static struct seq_operations fib_trie_seq_ops = { | 2428 | static struct seq_operations fib_route_seq_ops = { |
| 2486 | .start = fib_trie_seq_start, | 2429 | .start = fib_trie_seq_start, |
| 2487 | .next = fib_trie_seq_next, | 2430 | .next = fib_trie_seq_next, |
| 2488 | .stop = fib_trie_seq_stop, | 2431 | .stop = fib_trie_seq_stop, |
| 2489 | .show = fib_trie_seq_show, | 2432 | .show = fib_route_seq_show, |
| 2490 | }; | 2433 | }; |
| 2491 | 2434 | ||
| 2492 | static int fib_trie_seq_open(struct inode *inode, struct file *file) | 2435 | static int fib_route_seq_open(struct inode *inode, struct file *file) |
| 2493 | { | 2436 | { |
| 2494 | struct seq_file *seq; | 2437 | struct seq_file *seq; |
| 2495 | int rc = -ENOMEM; | 2438 | int rc = -ENOMEM; |
| 2439 | struct fib_trie_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); | ||
| 2496 | 2440 | ||
| 2497 | rc = seq_open(file, &fib_trie_seq_ops); | 2441 | if (!s) |
| 2442 | goto out; | ||
| 2443 | |||
| 2444 | rc = seq_open(file, &fib_route_seq_ops); | ||
| 2498 | if (rc) | 2445 | if (rc) |
| 2499 | goto out_kfree; | 2446 | goto out_kfree; |
| 2500 | 2447 | ||
| 2501 | seq = file->private_data; | 2448 | seq = file->private_data; |
| 2449 | seq->private = s; | ||
| 2450 | memset(s, 0, sizeof(*s)); | ||
| 2502 | out: | 2451 | out: |
| 2503 | return rc; | 2452 | return rc; |
| 2504 | out_kfree: | 2453 | out_kfree: |
| 2454 | kfree(s); | ||
| 2505 | goto out; | 2455 | goto out; |
| 2506 | } | 2456 | } |
| 2507 | 2457 | ||
| 2508 | static struct file_operations fib_trie_seq_fops = { | 2458 | static struct file_operations fib_route_fops = { |
| 2509 | .owner = THIS_MODULE, | 2459 | .owner = THIS_MODULE, |
| 2510 | .open = fib_trie_seq_open, | 2460 | .open = fib_route_seq_open, |
| 2511 | .read = seq_read, | 2461 | .read = seq_read, |
| 2512 | .llseek = seq_lseek, | 2462 | .llseek = seq_lseek, |
| 2513 | .release= seq_release_private, | 2463 | .release = seq_release_private, |
| 2514 | }; | 2464 | }; |
| 2515 | 2465 | ||
| 2516 | int __init fib_proc_init(void) | 2466 | int __init fib_proc_init(void) |
| 2517 | { | 2467 | { |
| 2518 | if (!proc_net_fops_create("fib_trie", S_IRUGO, &fib_trie_seq_fops)) | 2468 | if (!proc_net_fops_create("fib_trie", S_IRUGO, &fib_trie_fops)) |
| 2519 | return -ENOMEM; | 2469 | goto out1; |
| 2470 | |||
| 2471 | if (!proc_net_fops_create("fib_triestat", S_IRUGO, &fib_triestat_fops)) | ||
| 2472 | goto out2; | ||
| 2473 | |||
| 2474 | if (!proc_net_fops_create("route", S_IRUGO, &fib_route_fops)) | ||
| 2475 | goto out3; | ||
| 2476 | |||
| 2520 | return 0; | 2477 | return 0; |
| 2478 | |||
| 2479 | out3: | ||
| 2480 | proc_net_remove("fib_triestat"); | ||
| 2481 | out2: | ||
| 2482 | proc_net_remove("fib_trie"); | ||
| 2483 | out1: | ||
| 2484 | return -ENOMEM; | ||
| 2521 | } | 2485 | } |
| 2522 | 2486 | ||
| 2523 | void __init fib_proc_exit(void) | 2487 | void __init fib_proc_exit(void) |
| 2524 | { | 2488 | { |
| 2525 | proc_net_remove("fib_trie"); | 2489 | proc_net_remove("fib_trie"); |
| 2490 | proc_net_remove("fib_triestat"); | ||
| 2491 | proc_net_remove("route"); | ||
| 2526 | } | 2492 | } |
| 2527 | 2493 | ||
| 2528 | #endif /* CONFIG_PROC_FS */ | 2494 | #endif /* CONFIG_PROC_FS */ |
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c index f84ba9c96551..2fc3fd38924f 100644 --- a/net/ipv4/inetpeer.c +++ b/net/ipv4/inetpeer.c | |||
| @@ -100,8 +100,7 @@ DEFINE_SPINLOCK(inet_peer_unused_lock); | |||
| 100 | #define PEER_MAX_CLEANUP_WORK 30 | 100 | #define PEER_MAX_CLEANUP_WORK 30 |
| 101 | 101 | ||
| 102 | static void peer_check_expire(unsigned long dummy); | 102 | static void peer_check_expire(unsigned long dummy); |
| 103 | static struct timer_list peer_periodic_timer = | 103 | static DEFINE_TIMER(peer_periodic_timer, peer_check_expire, 0, 0); |
| 104 | TIMER_INITIALIZER(peer_check_expire, 0, 0); | ||
| 105 | 104 | ||
| 106 | /* Exported for sysctl_net_ipv4. */ | 105 | /* Exported for sysctl_net_ipv4. */ |
| 107 | int inet_peer_gc_mintime = 10 * HZ, | 106 | int inet_peer_gc_mintime = 10 * HZ, |
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) | |||
| 1103 | #endif | 1103 | #endif |
| 1104 | 1104 | ||
| 1105 | jiff = jiffies + (d->next ? CONF_INTER_TIMEOUT : timeout); | 1105 | jiff = jiffies + (d->next ? CONF_INTER_TIMEOUT : timeout); |
| 1106 | while (time_before(jiffies, jiff) && !ic_got_reply) { | 1106 | while (time_before(jiffies, jiff) && !ic_got_reply) |
| 1107 | set_current_state(TASK_UNINTERRUPTIBLE); | 1107 | schedule_timeout_uninterruptible(1); |
| 1108 | schedule_timeout(1); | ||
| 1109 | } | ||
| 1110 | #ifdef IPCONFIG_DHCP | 1108 | #ifdef IPCONFIG_DHCP |
| 1111 | /* DHCP isn't done until we get a DHCPACK. */ | 1109 | /* DHCP isn't done until we get a DHCPACK. */ |
| 1112 | if ((ic_got_reply & IC_BOOTP) | 1110 | if ((ic_got_reply & IC_BOOTP) |
diff --git a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c index 2b5cf9c51309..bb7246683b74 100644 --- a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c +++ b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c | |||
| @@ -104,12 +104,28 @@ out: | |||
| 104 | static struct ip_conntrack_helper helper = { | 104 | static struct ip_conntrack_helper helper = { |
| 105 | .name = "netbios-ns", | 105 | .name = "netbios-ns", |
| 106 | .tuple = { | 106 | .tuple = { |
| 107 | .src.u.udp.port = __constant_htons(137), | 107 | .src = { |
| 108 | .dst.protonum = IPPROTO_UDP, | 108 | .u = { |
| 109 | .udp = { | ||
| 110 | .port = __constant_htons(137), | ||
| 111 | } | ||
| 112 | } | ||
| 113 | }, | ||
| 114 | .dst = { | ||
| 115 | .protonum = IPPROTO_UDP, | ||
| 116 | }, | ||
| 109 | }, | 117 | }, |
| 110 | .mask = { | 118 | .mask = { |
| 111 | .src.u.udp.port = 0xFFFF, | 119 | .src = { |
| 112 | .dst.protonum = 0xFF, | 120 | .u = { |
| 121 | .udp = { | ||
| 122 | .port = 0xFFFF, | ||
| 123 | } | ||
| 124 | } | ||
| 125 | }, | ||
| 126 | .dst = { | ||
| 127 | .protonum = 0xFF, | ||
| 128 | }, | ||
| 113 | }, | 129 | }, |
| 114 | .max_expected = 1, | 130 | .max_expected = 1, |
| 115 | .me = THIS_MODULE, | 131 | .me = THIS_MODULE, |
diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c index f115a84a4ac6..f057025a719e 100644 --- a/net/ipv4/netfilter/ipt_REJECT.c +++ b/net/ipv4/netfilter/ipt_REJECT.c | |||
| @@ -92,10 +92,7 @@ static inline struct rtable *route_reverse(struct sk_buff *skb, | |||
| 92 | fl.fl_ip_sport = tcph->dest; | 92 | fl.fl_ip_sport = tcph->dest; |
| 93 | fl.fl_ip_dport = tcph->source; | 93 | fl.fl_ip_dport = tcph->source; |
| 94 | 94 | ||
| 95 | if (xfrm_lookup((struct dst_entry **)&rt, &fl, NULL, 0)) { | 95 | xfrm_lookup((struct dst_entry **)&rt, &fl, NULL, 0); |
| 96 | dst_release(&rt->u.dst); | ||
| 97 | rt = NULL; | ||
| 98 | } | ||
| 99 | 96 | ||
| 100 | return rt; | 97 | return rt; |
| 101 | } | 98 | } |
diff --git a/net/ipv4/netfilter/ipt_owner.c b/net/ipv4/netfilter/ipt_owner.c index c1889f88262b..0cee2862ed85 100644 --- a/net/ipv4/netfilter/ipt_owner.c +++ b/net/ipv4/netfilter/ipt_owner.c | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
| 12 | #include <linux/skbuff.h> | 12 | #include <linux/skbuff.h> |
| 13 | #include <linux/file.h> | 13 | #include <linux/file.h> |
| 14 | #include <linux/rcupdate.h> | ||
| 14 | #include <net/sock.h> | 15 | #include <net/sock.h> |
| 15 | 16 | ||
| 16 | #include <linux/netfilter_ipv4/ipt_owner.h> | 17 | #include <linux/netfilter_ipv4/ipt_owner.h> |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 8c0b14e3beec..8549f26e2495 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
| @@ -1760,6 +1760,7 @@ static inline int __mkroute_input(struct sk_buff *skb, | |||
| 1760 | goto cleanup; | 1760 | goto cleanup; |
| 1761 | } | 1761 | } |
| 1762 | 1762 | ||
| 1763 | atomic_set(&rth->u.dst.__refcnt, 1); | ||
| 1763 | rth->u.dst.flags= DST_HOST; | 1764 | rth->u.dst.flags= DST_HOST; |
| 1764 | #ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED | 1765 | #ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED |
| 1765 | if (res->fi->fib_nhs > 1) | 1766 | if (res->fi->fib_nhs > 1) |
| @@ -1820,7 +1821,6 @@ static inline int ip_mkroute_input_def(struct sk_buff *skb, | |||
| 1820 | err = __mkroute_input(skb, res, in_dev, daddr, saddr, tos, &rth); | 1821 | err = __mkroute_input(skb, res, in_dev, daddr, saddr, tos, &rth); |
| 1821 | if (err) | 1822 | if (err) |
| 1822 | return err; | 1823 | return err; |
| 1823 | atomic_set(&rth->u.dst.__refcnt, 1); | ||
| 1824 | 1824 | ||
| 1825 | /* put it into the cache */ | 1825 | /* put it into the cache */ |
| 1826 | hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5), tos); | 1826 | hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5), tos); |
| @@ -1834,8 +1834,8 @@ static inline int ip_mkroute_input(struct sk_buff *skb, | |||
| 1834 | u32 daddr, u32 saddr, u32 tos) | 1834 | u32 daddr, u32 saddr, u32 tos) |
| 1835 | { | 1835 | { |
| 1836 | #ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED | 1836 | #ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED |
| 1837 | struct rtable* rth = NULL; | 1837 | struct rtable* rth = NULL, *rtres; |
| 1838 | unsigned char hop, hopcount, lasthop; | 1838 | unsigned char hop, hopcount; |
| 1839 | int err = -EINVAL; | 1839 | int err = -EINVAL; |
| 1840 | unsigned int hash; | 1840 | unsigned int hash; |
| 1841 | 1841 | ||
| @@ -1844,8 +1844,6 @@ static inline int ip_mkroute_input(struct sk_buff *skb, | |||
| 1844 | else | 1844 | else |
| 1845 | hopcount = 1; | 1845 | hopcount = 1; |
| 1846 | 1846 | ||
| 1847 | lasthop = hopcount - 1; | ||
| 1848 | |||
| 1849 | /* distinguish between multipath and singlepath */ | 1847 | /* distinguish between multipath and singlepath */ |
| 1850 | if (hopcount < 2) | 1848 | if (hopcount < 2) |
| 1851 | return ip_mkroute_input_def(skb, res, fl, in_dev, daddr, | 1849 | return ip_mkroute_input_def(skb, res, fl, in_dev, daddr, |
| @@ -1855,6 +1853,10 @@ static inline int ip_mkroute_input(struct sk_buff *skb, | |||
| 1855 | for (hop = 0; hop < hopcount; hop++) { | 1853 | for (hop = 0; hop < hopcount; hop++) { |
| 1856 | res->nh_sel = hop; | 1854 | res->nh_sel = hop; |
| 1857 | 1855 | ||
| 1856 | /* put reference to previous result */ | ||
| 1857 | if (hop) | ||
| 1858 | ip_rt_put(rtres); | ||
| 1859 | |||
| 1858 | /* create a routing cache entry */ | 1860 | /* create a routing cache entry */ |
| 1859 | err = __mkroute_input(skb, res, in_dev, daddr, saddr, tos, | 1861 | err = __mkroute_input(skb, res, in_dev, daddr, saddr, tos, |
| 1860 | &rth); | 1862 | &rth); |
| @@ -1863,7 +1865,7 @@ static inline int ip_mkroute_input(struct sk_buff *skb, | |||
| 1863 | 1865 | ||
| 1864 | /* put it into the cache */ | 1866 | /* put it into the cache */ |
| 1865 | hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5), tos); | 1867 | hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5), tos); |
| 1866 | err = rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); | 1868 | err = rt_intern_hash(hash, rth, &rtres); |
| 1867 | if (err) | 1869 | if (err) |
| 1868 | return err; | 1870 | return err; |
| 1869 | 1871 | ||
| @@ -1873,13 +1875,8 @@ static inline int ip_mkroute_input(struct sk_buff *skb, | |||
| 1873 | FIB_RES_NETMASK(*res), | 1875 | FIB_RES_NETMASK(*res), |
| 1874 | res->prefixlen, | 1876 | res->prefixlen, |
| 1875 | &FIB_RES_NH(*res)); | 1877 | &FIB_RES_NH(*res)); |
| 1876 | |||
| 1877 | /* only for the last hop the reference count is handled | ||
| 1878 | * outside | ||
| 1879 | */ | ||
| 1880 | if (hop == lasthop) | ||
| 1881 | atomic_set(&(skb->dst->__refcnt), 1); | ||
| 1882 | } | 1878 | } |
| 1879 | skb->dst = &rtres->u.dst; | ||
| 1883 | return err; | 1880 | return err; |
| 1884 | #else /* CONFIG_IP_ROUTE_MULTIPATH_CACHED */ | 1881 | #else /* CONFIG_IP_ROUTE_MULTIPATH_CACHED */ |
| 1885 | return ip_mkroute_input_def(skb, res, fl, in_dev, daddr, saddr, tos); | 1882 | return ip_mkroute_input_def(skb, res, fl, in_dev, daddr, saddr, tos); |
| @@ -2208,6 +2205,7 @@ static inline int __mkroute_output(struct rtable **result, | |||
| 2208 | goto cleanup; | 2205 | goto cleanup; |
| 2209 | } | 2206 | } |
| 2210 | 2207 | ||
| 2208 | atomic_set(&rth->u.dst.__refcnt, 1); | ||
| 2211 | rth->u.dst.flags= DST_HOST; | 2209 | rth->u.dst.flags= DST_HOST; |
| 2212 | #ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED | 2210 | #ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED |
| 2213 | if (res->fi) { | 2211 | if (res->fi) { |
| @@ -2290,8 +2288,6 @@ static inline int ip_mkroute_output_def(struct rtable **rp, | |||
| 2290 | if (err == 0) { | 2288 | if (err == 0) { |
| 2291 | u32 tos = RT_FL_TOS(oldflp); | 2289 | u32 tos = RT_FL_TOS(oldflp); |
| 2292 | 2290 | ||
| 2293 | atomic_set(&rth->u.dst.__refcnt, 1); | ||
| 2294 | |||
| 2295 | hash = rt_hash_code(oldflp->fl4_dst, | 2291 | hash = rt_hash_code(oldflp->fl4_dst, |
| 2296 | oldflp->fl4_src ^ (oldflp->oif << 5), tos); | 2292 | oldflp->fl4_src ^ (oldflp->oif << 5), tos); |
| 2297 | err = rt_intern_hash(hash, rth, rp); | 2293 | err = rt_intern_hash(hash, rth, rp); |
| @@ -2326,6 +2322,10 @@ static inline int ip_mkroute_output(struct rtable** rp, | |||
| 2326 | dev2nexthop = FIB_RES_DEV(*res); | 2322 | dev2nexthop = FIB_RES_DEV(*res); |
| 2327 | dev_hold(dev2nexthop); | 2323 | dev_hold(dev2nexthop); |
| 2328 | 2324 | ||
| 2325 | /* put reference to previous result */ | ||
| 2326 | if (hop) | ||
| 2327 | ip_rt_put(*rp); | ||
| 2328 | |||
| 2329 | err = __mkroute_output(&rth, res, fl, oldflp, | 2329 | err = __mkroute_output(&rth, res, fl, oldflp, |
| 2330 | dev2nexthop, flags); | 2330 | dev2nexthop, flags); |
| 2331 | 2331 | ||
| @@ -2350,7 +2350,6 @@ static inline int ip_mkroute_output(struct rtable** rp, | |||
| 2350 | if (err != 0) | 2350 | if (err != 0) |
| 2351 | return err; | 2351 | return err; |
| 2352 | } | 2352 | } |
| 2353 | atomic_set(&(*rp)->u.dst.__refcnt, 1); | ||
| 2354 | return err; | 2353 | return err; |
| 2355 | } else { | 2354 | } else { |
| 2356 | return ip_mkroute_output_def(rp, res, fl, oldflp, dev_out, | 2355 | return ip_mkroute_output_def(rp, res, fl, oldflp, dev_out, |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 6094db5e11be..c10e4435e3b1 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
| @@ -485,11 +485,6 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss | |||
| 485 | TCP_SKB_CB(buff)->when = TCP_SKB_CB(skb)->when; | 485 | TCP_SKB_CB(buff)->when = TCP_SKB_CB(skb)->when; |
| 486 | buff->tstamp = skb->tstamp; | 486 | buff->tstamp = skb->tstamp; |
| 487 | 487 | ||
| 488 | if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST) { | ||
| 489 | tp->lost_out -= tcp_skb_pcount(skb); | ||
| 490 | tp->left_out -= tcp_skb_pcount(skb); | ||
| 491 | } | ||
| 492 | |||
| 493 | old_factor = tcp_skb_pcount(skb); | 488 | old_factor = tcp_skb_pcount(skb); |
| 494 | 489 | ||
| 495 | /* Fix up tso_factor for both original and new SKB. */ | 490 | /* Fix up tso_factor for both original and new SKB. */ |
| @@ -499,7 +494,7 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss | |||
| 499 | /* If this packet has been sent out already, we must | 494 | /* If this packet has been sent out already, we must |
| 500 | * adjust the various packet counters. | 495 | * adjust the various packet counters. |
| 501 | */ | 496 | */ |
| 502 | if (after(tp->snd_nxt, TCP_SKB_CB(buff)->end_seq)) { | 497 | if (!before(tp->snd_nxt, TCP_SKB_CB(buff)->end_seq)) { |
| 503 | int diff = old_factor - tcp_skb_pcount(skb) - | 498 | int diff = old_factor - tcp_skb_pcount(skb) - |
| 504 | tcp_skb_pcount(buff); | 499 | tcp_skb_pcount(buff); |
| 505 | 500 | ||
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index e5beca7de86c..e0bd1013cb0d 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
| @@ -1141,7 +1141,7 @@ int udp_rcv(struct sk_buff *skb) | |||
| 1141 | if (ulen > len || ulen < sizeof(*uh)) | 1141 | if (ulen > len || ulen < sizeof(*uh)) |
| 1142 | goto short_packet; | 1142 | goto short_packet; |
| 1143 | 1143 | ||
| 1144 | if (pskb_trim(skb, ulen)) | 1144 | if (pskb_trim_rcsum(skb, ulen)) |
| 1145 | goto short_packet; | 1145 | goto short_packet; |
| 1146 | 1146 | ||
| 1147 | if (udp_checksum_init(skb, uh, ulen, saddr, daddr) < 0) | 1147 | if (udp_checksum_init(skb, uh, ulen, saddr, daddr) < 0) |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 6d6fb74f3b52..2fea3f4402a0 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
| @@ -123,8 +123,7 @@ DEFINE_RWLOCK(addrconf_lock); | |||
| 123 | 123 | ||
| 124 | static void addrconf_verify(unsigned long); | 124 | static void addrconf_verify(unsigned long); |
| 125 | 125 | ||
| 126 | static struct timer_list addr_chk_timer = | 126 | static DEFINE_TIMER(addr_chk_timer, addrconf_verify, 0, 0); |
| 127 | TIMER_INITIALIZER(addrconf_verify, 0, 0); | ||
| 128 | static DEFINE_SPINLOCK(addrconf_verify_lock); | 127 | static DEFINE_SPINLOCK(addrconf_verify_lock); |
| 129 | 128 | ||
| 130 | static void addrconf_join_anycast(struct inet6_ifaddr *ifp); | 129 | static void addrconf_join_anycast(struct inet6_ifaddr *ifp); |
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 01468fab3d3d..cc518405b3e1 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c | |||
| @@ -175,10 +175,8 @@ ipv4_connected: | |||
| 175 | if (final_p) | 175 | if (final_p) |
| 176 | ipv6_addr_copy(&fl.fl6_dst, final_p); | 176 | ipv6_addr_copy(&fl.fl6_dst, final_p); |
| 177 | 177 | ||
| 178 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { | 178 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) |
| 179 | dst_release(dst); | ||
| 180 | goto out; | 179 | goto out; |
| 181 | } | ||
| 182 | 180 | ||
| 183 | /* source address lookup done in ip6_dst_lookup */ | 181 | /* source address lookup done in ip6_dst_lookup */ |
| 184 | 182 | ||
| @@ -390,32 +388,101 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) | |||
| 390 | put_cmsg(msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim); | 388 | put_cmsg(msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim); |
| 391 | } | 389 | } |
| 392 | 390 | ||
| 391 | if (np->rxopt.bits.rxtclass) { | ||
| 392 | int tclass = (ntohl(*(u32 *)skb->nh.ipv6h) >> 20) & 0xff; | ||
| 393 | put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass); | ||
| 394 | } | ||
| 395 | |||
| 393 | if (np->rxopt.bits.rxflow && (*(u32*)skb->nh.raw & IPV6_FLOWINFO_MASK)) { | 396 | if (np->rxopt.bits.rxflow && (*(u32*)skb->nh.raw & IPV6_FLOWINFO_MASK)) { |
| 394 | u32 flowinfo = *(u32*)skb->nh.raw & IPV6_FLOWINFO_MASK; | 397 | u32 flowinfo = *(u32*)skb->nh.raw & IPV6_FLOWINFO_MASK; |
| 395 | put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo); | 398 | put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo); |
| 396 | } | 399 | } |
| 400 | |||
| 401 | /* HbH is allowed only once */ | ||
| 397 | if (np->rxopt.bits.hopopts && opt->hop) { | 402 | if (np->rxopt.bits.hopopts && opt->hop) { |
| 398 | u8 *ptr = skb->nh.raw + opt->hop; | 403 | u8 *ptr = skb->nh.raw + opt->hop; |
| 399 | put_cmsg(msg, SOL_IPV6, IPV6_HOPOPTS, (ptr[1]+1)<<3, ptr); | 404 | put_cmsg(msg, SOL_IPV6, IPV6_HOPOPTS, (ptr[1]+1)<<3, ptr); |
| 400 | } | 405 | } |
| 401 | if (np->rxopt.bits.dstopts && opt->dst0) { | 406 | |
| 407 | if (opt->lastopt && | ||
| 408 | (np->rxopt.bits.dstopts || np->rxopt.bits.srcrt)) { | ||
| 409 | /* | ||
| 410 | * Silly enough, but we need to reparse in order to | ||
| 411 | * report extension headers (except for HbH) | ||
| 412 | * in order. | ||
| 413 | * | ||
| 414 | * Also note that IPV6_RECVRTHDRDSTOPTS is NOT | ||
| 415 | * (and WILL NOT be) defined because | ||
| 416 | * IPV6_RECVDSTOPTS is more generic. --yoshfuji | ||
| 417 | */ | ||
| 418 | unsigned int off = sizeof(struct ipv6hdr); | ||
| 419 | u8 nexthdr = skb->nh.ipv6h->nexthdr; | ||
| 420 | |||
| 421 | while (off <= opt->lastopt) { | ||
| 422 | unsigned len; | ||
| 423 | u8 *ptr = skb->nh.raw + off; | ||
| 424 | |||
| 425 | switch(nexthdr) { | ||
| 426 | case IPPROTO_DSTOPTS: | ||
| 427 | nexthdr = ptr[0]; | ||
| 428 | len = (ptr[1] + 1) << 3; | ||
| 429 | if (np->rxopt.bits.dstopts) | ||
| 430 | put_cmsg(msg, SOL_IPV6, IPV6_DSTOPTS, len, ptr); | ||
| 431 | break; | ||
| 432 | case IPPROTO_ROUTING: | ||
| 433 | nexthdr = ptr[0]; | ||
| 434 | len = (ptr[1] + 1) << 3; | ||
| 435 | if (np->rxopt.bits.srcrt) | ||
| 436 | put_cmsg(msg, SOL_IPV6, IPV6_RTHDR, len, ptr); | ||
| 437 | break; | ||
| 438 | case IPPROTO_AH: | ||
| 439 | nexthdr = ptr[0]; | ||
| 440 | len = (ptr[1] + 1) << 2; | ||
| 441 | break; | ||
| 442 | default: | ||
| 443 | nexthdr = ptr[0]; | ||
| 444 | len = (ptr[1] + 1) << 3; | ||
| 445 | break; | ||
| 446 | } | ||
| 447 | |||
| 448 | off += len; | ||
| 449 | } | ||
| 450 | } | ||
| 451 | |||
| 452 | /* socket options in old style */ | ||
| 453 | if (np->rxopt.bits.rxoinfo) { | ||
| 454 | struct in6_pktinfo src_info; | ||
| 455 | |||
| 456 | src_info.ipi6_ifindex = opt->iif; | ||
| 457 | ipv6_addr_copy(&src_info.ipi6_addr, &skb->nh.ipv6h->daddr); | ||
| 458 | put_cmsg(msg, SOL_IPV6, IPV6_2292PKTINFO, sizeof(src_info), &src_info); | ||
| 459 | } | ||
| 460 | if (np->rxopt.bits.rxohlim) { | ||
| 461 | int hlim = skb->nh.ipv6h->hop_limit; | ||
| 462 | put_cmsg(msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim); | ||
| 463 | } | ||
| 464 | if (np->rxopt.bits.ohopopts && opt->hop) { | ||
| 465 | u8 *ptr = skb->nh.raw + opt->hop; | ||
| 466 | put_cmsg(msg, SOL_IPV6, IPV6_2292HOPOPTS, (ptr[1]+1)<<3, ptr); | ||
| 467 | } | ||
| 468 | if (np->rxopt.bits.odstopts && opt->dst0) { | ||
| 402 | u8 *ptr = skb->nh.raw + opt->dst0; | 469 | u8 *ptr = skb->nh.raw + opt->dst0; |
| 403 | put_cmsg(msg, SOL_IPV6, IPV6_DSTOPTS, (ptr[1]+1)<<3, ptr); | 470 | put_cmsg(msg, SOL_IPV6, IPV6_2292DSTOPTS, (ptr[1]+1)<<3, ptr); |
| 404 | } | 471 | } |
| 405 | if (np->rxopt.bits.srcrt && opt->srcrt) { | 472 | if (np->rxopt.bits.osrcrt && opt->srcrt) { |
| 406 | struct ipv6_rt_hdr *rthdr = (struct ipv6_rt_hdr *)(skb->nh.raw + opt->srcrt); | 473 | struct ipv6_rt_hdr *rthdr = (struct ipv6_rt_hdr *)(skb->nh.raw + opt->srcrt); |
| 407 | put_cmsg(msg, SOL_IPV6, IPV6_RTHDR, (rthdr->hdrlen+1) << 3, rthdr); | 474 | put_cmsg(msg, SOL_IPV6, IPV6_2292RTHDR, (rthdr->hdrlen+1) << 3, rthdr); |
| 408 | } | 475 | } |
| 409 | if (np->rxopt.bits.dstopts && opt->dst1) { | 476 | if (np->rxopt.bits.odstopts && opt->dst1) { |
| 410 | u8 *ptr = skb->nh.raw + opt->dst1; | 477 | u8 *ptr = skb->nh.raw + opt->dst1; |
| 411 | put_cmsg(msg, SOL_IPV6, IPV6_DSTOPTS, (ptr[1]+1)<<3, ptr); | 478 | put_cmsg(msg, SOL_IPV6, IPV6_2292DSTOPTS, (ptr[1]+1)<<3, ptr); |
| 412 | } | 479 | } |
| 413 | return 0; | 480 | return 0; |
| 414 | } | 481 | } |
| 415 | 482 | ||
| 416 | int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | 483 | int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, |
| 417 | struct ipv6_txoptions *opt, | 484 | struct ipv6_txoptions *opt, |
| 418 | int *hlimit) | 485 | int *hlimit, int *tclass) |
| 419 | { | 486 | { |
| 420 | struct in6_pktinfo *src_info; | 487 | struct in6_pktinfo *src_info; |
| 421 | struct cmsghdr *cmsg; | 488 | struct cmsghdr *cmsg; |
| @@ -438,6 +505,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | |||
| 438 | 505 | ||
| 439 | switch (cmsg->cmsg_type) { | 506 | switch (cmsg->cmsg_type) { |
| 440 | case IPV6_PKTINFO: | 507 | case IPV6_PKTINFO: |
| 508 | case IPV6_2292PKTINFO: | ||
| 441 | if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct in6_pktinfo))) { | 509 | if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct in6_pktinfo))) { |
| 442 | err = -EINVAL; | 510 | err = -EINVAL; |
| 443 | goto exit_f; | 511 | goto exit_f; |
| @@ -492,6 +560,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | |||
| 492 | fl->fl6_flowlabel = IPV6_FLOWINFO_MASK & *(u32 *)CMSG_DATA(cmsg); | 560 | fl->fl6_flowlabel = IPV6_FLOWINFO_MASK & *(u32 *)CMSG_DATA(cmsg); |
| 493 | break; | 561 | break; |
| 494 | 562 | ||
| 563 | case IPV6_2292HOPOPTS: | ||
| 495 | case IPV6_HOPOPTS: | 564 | case IPV6_HOPOPTS: |
| 496 | if (opt->hopopt || cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { | 565 | if (opt->hopopt || cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { |
| 497 | err = -EINVAL; | 566 | err = -EINVAL; |
| @@ -512,7 +581,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | |||
| 512 | opt->hopopt = hdr; | 581 | opt->hopopt = hdr; |
| 513 | break; | 582 | break; |
| 514 | 583 | ||
| 515 | case IPV6_DSTOPTS: | 584 | case IPV6_2292DSTOPTS: |
| 516 | if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { | 585 | if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { |
| 517 | err = -EINVAL; | 586 | err = -EINVAL; |
| 518 | goto exit_f; | 587 | goto exit_f; |
| @@ -536,6 +605,33 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | |||
| 536 | opt->dst1opt = hdr; | 605 | opt->dst1opt = hdr; |
| 537 | break; | 606 | break; |
| 538 | 607 | ||
| 608 | case IPV6_DSTOPTS: | ||
| 609 | case IPV6_RTHDRDSTOPTS: | ||
| 610 | if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { | ||
| 611 | err = -EINVAL; | ||
| 612 | goto exit_f; | ||
| 613 | } | ||
| 614 | |||
| 615 | hdr = (struct ipv6_opt_hdr *)CMSG_DATA(cmsg); | ||
| 616 | len = ((hdr->hdrlen + 1) << 3); | ||
| 617 | if (cmsg->cmsg_len < CMSG_LEN(len)) { | ||
| 618 | err = -EINVAL; | ||
| 619 | goto exit_f; | ||
| 620 | } | ||
| 621 | if (!capable(CAP_NET_RAW)) { | ||
| 622 | err = -EPERM; | ||
| 623 | goto exit_f; | ||
| 624 | } | ||
| 625 | if (cmsg->cmsg_type == IPV6_DSTOPTS) { | ||
| 626 | opt->opt_flen += len; | ||
| 627 | opt->dst1opt = hdr; | ||
| 628 | } else { | ||
| 629 | opt->opt_nflen += len; | ||
| 630 | opt->dst0opt = hdr; | ||
| 631 | } | ||
| 632 | break; | ||
| 633 | |||
| 634 | case IPV6_2292RTHDR: | ||
| 539 | case IPV6_RTHDR: | 635 | case IPV6_RTHDR: |
| 540 | if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_rt_hdr))) { | 636 | if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_rt_hdr))) { |
| 541 | err = -EINVAL; | 637 | err = -EINVAL; |
| @@ -568,7 +664,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | |||
| 568 | opt->opt_nflen += len; | 664 | opt->opt_nflen += len; |
| 569 | opt->srcrt = rthdr; | 665 | opt->srcrt = rthdr; |
| 570 | 666 | ||
| 571 | if (opt->dst1opt) { | 667 | if (cmsg->cmsg_type == IPV6_2292RTHDR && opt->dst1opt) { |
| 572 | int dsthdrlen = ((opt->dst1opt->hdrlen+1)<<3); | 668 | int dsthdrlen = ((opt->dst1opt->hdrlen+1)<<3); |
| 573 | 669 | ||
| 574 | opt->opt_nflen += dsthdrlen; | 670 | opt->opt_nflen += dsthdrlen; |
| @@ -579,6 +675,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | |||
| 579 | 675 | ||
| 580 | break; | 676 | break; |
| 581 | 677 | ||
| 678 | case IPV6_2292HOPLIMIT: | ||
| 582 | case IPV6_HOPLIMIT: | 679 | case IPV6_HOPLIMIT: |
| 583 | if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) { | 680 | if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) { |
| 584 | err = -EINVAL; | 681 | err = -EINVAL; |
| @@ -588,6 +685,24 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | |||
| 588 | *hlimit = *(int *)CMSG_DATA(cmsg); | 685 | *hlimit = *(int *)CMSG_DATA(cmsg); |
| 589 | break; | 686 | break; |
| 590 | 687 | ||
| 688 | case IPV6_TCLASS: | ||
| 689 | { | ||
| 690 | int tc; | ||
| 691 | |||
| 692 | err = -EINVAL; | ||
| 693 | if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) { | ||
| 694 | goto exit_f; | ||
| 695 | } | ||
| 696 | |||
| 697 | tc = *(int *)CMSG_DATA(cmsg); | ||
| 698 | if (tc < 0 || tc > 0xff) | ||
| 699 | goto exit_f; | ||
| 700 | |||
| 701 | err = 0; | ||
| 702 | *tclass = tc; | ||
| 703 | |||
| 704 | break; | ||
| 705 | } | ||
| 591 | default: | 706 | default: |
| 592 | LIMIT_NETDEBUG(KERN_DEBUG "invalid cmsg type: %d\n", | 707 | LIMIT_NETDEBUG(KERN_DEBUG "invalid cmsg type: %d\n", |
| 593 | cmsg->cmsg_type); | 708 | cmsg->cmsg_type); |
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c index 5be6da2584ee..922549581abc 100644 --- a/net/ipv6/exthdrs.c +++ b/net/ipv6/exthdrs.c | |||
| @@ -164,6 +164,7 @@ static int ipv6_destopt_rcv(struct sk_buff **skbp, unsigned int *nhoffp) | |||
| 164 | return -1; | 164 | return -1; |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | opt->lastopt = skb->h.raw - skb->nh.raw; | ||
| 167 | opt->dst1 = skb->h.raw - skb->nh.raw; | 168 | opt->dst1 = skb->h.raw - skb->nh.raw; |
| 168 | 169 | ||
| 169 | if (ip6_parse_tlv(tlvprocdestopt_lst, skb)) { | 170 | if (ip6_parse_tlv(tlvprocdestopt_lst, skb)) { |
| @@ -243,6 +244,7 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp, unsigned int *nhoffp) | |||
| 243 | 244 | ||
| 244 | looped_back: | 245 | looped_back: |
| 245 | if (hdr->segments_left == 0) { | 246 | if (hdr->segments_left == 0) { |
| 247 | opt->lastopt = skb->h.raw - skb->nh.raw; | ||
| 246 | opt->srcrt = skb->h.raw - skb->nh.raw; | 248 | opt->srcrt = skb->h.raw - skb->nh.raw; |
| 247 | skb->h.raw += (hdr->hdrlen + 1) << 3; | 249 | skb->h.raw += (hdr->hdrlen + 1) << 3; |
| 248 | opt->dst0 = opt->dst1; | 250 | opt->dst0 = opt->dst1; |
| @@ -404,8 +406,7 @@ ipv6_invert_rthdr(struct sock *sk, struct ipv6_rt_hdr *hdr) | |||
| 404 | 406 | ||
| 405 | memcpy(opt->srcrt, hdr, sizeof(*hdr)); | 407 | memcpy(opt->srcrt, hdr, sizeof(*hdr)); |
| 406 | irthdr = (struct rt0_hdr*)opt->srcrt; | 408 | irthdr = (struct rt0_hdr*)opt->srcrt; |
| 407 | /* Obsolete field, MBZ, when originated by us */ | 409 | irthdr->reserved = 0; |
| 408 | irthdr->bitmap = 0; | ||
| 409 | opt->srcrt->segments_left = n; | 410 | opt->srcrt->segments_left = n; |
| 410 | for (i=0; i<n; i++) | 411 | for (i=0; i<n; i++) |
| 411 | memcpy(irthdr->addr+i, rthdr->addr+(n-1-i), 16); | 412 | memcpy(irthdr->addr+i, rthdr->addr+(n-1-i), 16); |
| @@ -459,11 +460,10 @@ static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff) | |||
| 459 | IP6_INC_STATS_BH(IPSTATS_MIB_INTRUNCATEDPKTS); | 460 | IP6_INC_STATS_BH(IPSTATS_MIB_INTRUNCATEDPKTS); |
| 460 | goto drop; | 461 | goto drop; |
| 461 | } | 462 | } |
| 462 | if (pkt_len + sizeof(struct ipv6hdr) < skb->len) { | 463 | |
| 463 | __pskb_trim(skb, pkt_len + sizeof(struct ipv6hdr)); | 464 | if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr))) |
| 464 | if (skb->ip_summed == CHECKSUM_HW) | 465 | goto drop; |
| 465 | skb->ip_summed = CHECKSUM_NONE; | 466 | |
| 466 | } | ||
| 467 | return 1; | 467 | return 1; |
| 468 | 468 | ||
| 469 | drop: | 469 | drop: |
| @@ -539,10 +539,15 @@ void ipv6_push_nfrag_opts(struct sk_buff *skb, struct ipv6_txoptions *opt, | |||
| 539 | u8 *proto, | 539 | u8 *proto, |
| 540 | struct in6_addr **daddr) | 540 | struct in6_addr **daddr) |
| 541 | { | 541 | { |
| 542 | if (opt->srcrt) | 542 | if (opt->srcrt) { |
| 543 | ipv6_push_rthdr(skb, proto, opt->srcrt, daddr); | 543 | ipv6_push_rthdr(skb, proto, opt->srcrt, daddr); |
| 544 | if (opt->dst0opt) | 544 | /* |
| 545 | ipv6_push_exthdr(skb, proto, NEXTHDR_DEST, opt->dst0opt); | 545 | * IPV6_RTHDRDSTOPTS is ignored |
| 546 | * unless IPV6_RTHDR is set (RFC3542). | ||
| 547 | */ | ||
| 548 | if (opt->dst0opt) | ||
| 549 | ipv6_push_exthdr(skb, proto, NEXTHDR_DEST, opt->dst0opt); | ||
| 550 | } | ||
| 546 | if (opt->hopopt) | 551 | if (opt->hopopt) |
| 547 | ipv6_push_exthdr(skb, proto, NEXTHDR_HOP, opt->hopopt); | 552 | ipv6_push_exthdr(skb, proto, NEXTHDR_HOP, opt->hopopt); |
| 548 | } | 553 | } |
| @@ -573,3 +578,97 @@ ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt) | |||
| 573 | } | 578 | } |
| 574 | return opt2; | 579 | return opt2; |
| 575 | } | 580 | } |
| 581 | |||
| 582 | static int ipv6_renew_option(void *ohdr, | ||
| 583 | struct ipv6_opt_hdr __user *newopt, int newoptlen, | ||
| 584 | int inherit, | ||
| 585 | struct ipv6_opt_hdr **hdr, | ||
| 586 | char **p) | ||
| 587 | { | ||
| 588 | if (inherit) { | ||
| 589 | if (ohdr) { | ||
| 590 | memcpy(*p, ohdr, ipv6_optlen((struct ipv6_opt_hdr *)ohdr)); | ||
| 591 | *hdr = (struct ipv6_opt_hdr *)*p; | ||
| 592 | *p += CMSG_ALIGN(ipv6_optlen(*(struct ipv6_opt_hdr **)hdr)); | ||
| 593 | } | ||
| 594 | } else { | ||
| 595 | if (newopt) { | ||
| 596 | if (copy_from_user(*p, newopt, newoptlen)) | ||
| 597 | return -EFAULT; | ||
| 598 | *hdr = (struct ipv6_opt_hdr *)*p; | ||
| 599 | if (ipv6_optlen(*(struct ipv6_opt_hdr **)hdr) > newoptlen) | ||
| 600 | return -EINVAL; | ||
| 601 | *p += CMSG_ALIGN(newoptlen); | ||
| 602 | } | ||
| 603 | } | ||
| 604 | return 0; | ||
| 605 | } | ||
| 606 | |||
| 607 | struct ipv6_txoptions * | ||
| 608 | ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt, | ||
| 609 | int newtype, | ||
| 610 | struct ipv6_opt_hdr __user *newopt, int newoptlen) | ||
| 611 | { | ||
| 612 | int tot_len = 0; | ||
| 613 | char *p; | ||
| 614 | struct ipv6_txoptions *opt2; | ||
| 615 | int err; | ||
| 616 | |||
| 617 | if (newtype != IPV6_HOPOPTS && opt->hopopt) | ||
| 618 | tot_len += CMSG_ALIGN(ipv6_optlen(opt->hopopt)); | ||
| 619 | if (newtype != IPV6_RTHDRDSTOPTS && opt->dst0opt) | ||
| 620 | tot_len += CMSG_ALIGN(ipv6_optlen(opt->dst0opt)); | ||
| 621 | if (newtype != IPV6_RTHDR && opt->srcrt) | ||
| 622 | tot_len += CMSG_ALIGN(ipv6_optlen(opt->srcrt)); | ||
| 623 | if (newtype != IPV6_DSTOPTS && opt->dst1opt) | ||
| 624 | tot_len += CMSG_ALIGN(ipv6_optlen(opt->dst1opt)); | ||
| 625 | if (newopt && newoptlen) | ||
| 626 | tot_len += CMSG_ALIGN(newoptlen); | ||
| 627 | |||
| 628 | if (!tot_len) | ||
| 629 | return NULL; | ||
| 630 | |||
| 631 | opt2 = sock_kmalloc(sk, tot_len, GFP_ATOMIC); | ||
| 632 | if (!opt2) | ||
| 633 | return ERR_PTR(-ENOBUFS); | ||
| 634 | |||
| 635 | memset(opt2, 0, tot_len); | ||
| 636 | |||
| 637 | opt2->tot_len = tot_len; | ||
| 638 | p = (char *)(opt2 + 1); | ||
| 639 | |||
| 640 | err = ipv6_renew_option(opt->hopopt, newopt, newoptlen, | ||
| 641 | newtype != IPV6_HOPOPTS, | ||
| 642 | &opt2->hopopt, &p); | ||
| 643 | if (err) | ||
| 644 | goto out; | ||
| 645 | |||
| 646 | err = ipv6_renew_option(opt->dst0opt, newopt, newoptlen, | ||
| 647 | newtype != IPV6_RTHDRDSTOPTS, | ||
| 648 | &opt2->dst0opt, &p); | ||
| 649 | if (err) | ||
| 650 | goto out; | ||
| 651 | |||
| 652 | err = ipv6_renew_option(opt->srcrt, newopt, newoptlen, | ||
| 653 | newtype != IPV6_RTHDR, | ||
| 654 | (struct ipv6_opt_hdr **)opt2->srcrt, &p); | ||
| 655 | if (err) | ||
| 656 | goto out; | ||
| 657 | |||
| 658 | err = ipv6_renew_option(opt->dst1opt, newopt, newoptlen, | ||
| 659 | newtype != IPV6_DSTOPTS, | ||
| 660 | &opt2->dst1opt, &p); | ||
| 661 | if (err) | ||
| 662 | goto out; | ||
| 663 | |||
| 664 | opt2->opt_nflen = (opt2->hopopt ? ipv6_optlen(opt2->hopopt) : 0) + | ||
| 665 | (opt2->dst0opt ? ipv6_optlen(opt2->dst0opt) : 0) + | ||
| 666 | (opt2->srcrt ? ipv6_optlen(opt2->srcrt) : 0); | ||
| 667 | opt2->opt_flen = (opt2->dst1opt ? ipv6_optlen(opt2->dst1opt) : 0); | ||
| 668 | |||
| 669 | return opt2; | ||
| 670 | out: | ||
| 671 | sock_kfree_s(sk, p, tot_len); | ||
| 672 | return ERR_PTR(err); | ||
| 673 | } | ||
| 674 | |||
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index fa8f1bb0aa52..b7185fb3377c 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
| @@ -287,7 +287,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, | |||
| 287 | int iif = 0; | 287 | int iif = 0; |
| 288 | int addr_type = 0; | 288 | int addr_type = 0; |
| 289 | int len; | 289 | int len; |
| 290 | int hlimit; | 290 | int hlimit, tclass; |
| 291 | int err = 0; | 291 | int err = 0; |
| 292 | 292 | ||
| 293 | if ((u8*)hdr < skb->head || (u8*)(hdr+1) > skb->tail) | 293 | if ((u8*)hdr < skb->head || (u8*)(hdr+1) > skb->tail) |
| @@ -374,7 +374,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, | |||
| 374 | if (err) | 374 | if (err) |
| 375 | goto out; | 375 | goto out; |
| 376 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) | 376 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) |
| 377 | goto out_dst_release; | 377 | goto out; |
| 378 | 378 | ||
| 379 | if (ipv6_addr_is_multicast(&fl.fl6_dst)) | 379 | if (ipv6_addr_is_multicast(&fl.fl6_dst)) |
| 380 | hlimit = np->mcast_hops; | 380 | hlimit = np->mcast_hops; |
| @@ -385,6 +385,10 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, | |||
| 385 | if (hlimit < 0) | 385 | if (hlimit < 0) |
| 386 | hlimit = ipv6_get_hoplimit(dst->dev); | 386 | hlimit = ipv6_get_hoplimit(dst->dev); |
| 387 | 387 | ||
| 388 | tclass = np->cork.tclass; | ||
| 389 | if (tclass < 0) | ||
| 390 | tclass = 0; | ||
| 391 | |||
| 388 | msg.skb = skb; | 392 | msg.skb = skb; |
| 389 | msg.offset = skb->nh.raw - skb->data; | 393 | msg.offset = skb->nh.raw - skb->data; |
| 390 | 394 | ||
| @@ -400,7 +404,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, | |||
| 400 | err = ip6_append_data(sk, icmpv6_getfrag, &msg, | 404 | err = ip6_append_data(sk, icmpv6_getfrag, &msg, |
| 401 | len + sizeof(struct icmp6hdr), | 405 | len + sizeof(struct icmp6hdr), |
| 402 | sizeof(struct icmp6hdr), | 406 | sizeof(struct icmp6hdr), |
| 403 | hlimit, NULL, &fl, (struct rt6_info*)dst, | 407 | hlimit, tclass, NULL, &fl, (struct rt6_info*)dst, |
| 404 | MSG_DONTWAIT); | 408 | MSG_DONTWAIT); |
| 405 | if (err) { | 409 | if (err) { |
| 406 | ip6_flush_pending_frames(sk); | 410 | ip6_flush_pending_frames(sk); |
| @@ -434,6 +438,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb) | |||
| 434 | struct dst_entry *dst; | 438 | struct dst_entry *dst; |
| 435 | int err = 0; | 439 | int err = 0; |
| 436 | int hlimit; | 440 | int hlimit; |
| 441 | int tclass; | ||
| 437 | 442 | ||
| 438 | saddr = &skb->nh.ipv6h->daddr; | 443 | saddr = &skb->nh.ipv6h->daddr; |
| 439 | 444 | ||
| @@ -464,7 +469,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb) | |||
| 464 | if (err) | 469 | if (err) |
| 465 | goto out; | 470 | goto out; |
| 466 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) | 471 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) |
| 467 | goto out_dst_release; | 472 | goto out; |
| 468 | 473 | ||
| 469 | if (ipv6_addr_is_multicast(&fl.fl6_dst)) | 474 | if (ipv6_addr_is_multicast(&fl.fl6_dst)) |
| 470 | hlimit = np->mcast_hops; | 475 | hlimit = np->mcast_hops; |
| @@ -475,13 +480,17 @@ static void icmpv6_echo_reply(struct sk_buff *skb) | |||
| 475 | if (hlimit < 0) | 480 | if (hlimit < 0) |
| 476 | hlimit = ipv6_get_hoplimit(dst->dev); | 481 | hlimit = ipv6_get_hoplimit(dst->dev); |
| 477 | 482 | ||
| 483 | tclass = np->cork.tclass; | ||
| 484 | if (tclass < 0) | ||
| 485 | tclass = 0; | ||
| 486 | |||
| 478 | idev = in6_dev_get(skb->dev); | 487 | idev = in6_dev_get(skb->dev); |
| 479 | 488 | ||
| 480 | msg.skb = skb; | 489 | msg.skb = skb; |
| 481 | msg.offset = 0; | 490 | msg.offset = 0; |
| 482 | 491 | ||
| 483 | err = ip6_append_data(sk, icmpv6_getfrag, &msg, skb->len + sizeof(struct icmp6hdr), | 492 | err = ip6_append_data(sk, icmpv6_getfrag, &msg, skb->len + sizeof(struct icmp6hdr), |
| 484 | sizeof(struct icmp6hdr), hlimit, NULL, &fl, | 493 | sizeof(struct icmp6hdr), hlimit, tclass, NULL, &fl, |
| 485 | (struct rt6_info*)dst, MSG_DONTWAIT); | 494 | (struct rt6_info*)dst, MSG_DONTWAIT); |
| 486 | 495 | ||
| 487 | if (err) { | 496 | if (err) { |
| @@ -496,7 +505,6 @@ static void icmpv6_echo_reply(struct sk_buff *skb) | |||
| 496 | out_put: | 505 | out_put: |
| 497 | if (likely(idev != NULL)) | 506 | if (likely(idev != NULL)) |
| 498 | in6_dev_put(idev); | 507 | in6_dev_put(idev); |
| 499 | out_dst_release: | ||
| 500 | dst_release(dst); | 508 | dst_release(dst); |
| 501 | out: | 509 | out: |
| 502 | icmpv6_xmit_unlock(); | 510 | icmpv6_xmit_unlock(); |
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 16af874c9e8f..4fcc5a7acf6e 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
| @@ -92,7 +92,7 @@ static struct fib6_node * fib6_repair_tree(struct fib6_node *fn); | |||
| 92 | 92 | ||
| 93 | static __u32 rt_sernum; | 93 | static __u32 rt_sernum; |
| 94 | 94 | ||
| 95 | static struct timer_list ip6_fib_timer = TIMER_INITIALIZER(fib6_run_gc, 0, 0); | 95 | static DEFINE_TIMER(ip6_fib_timer, fib6_run_gc, 0, 0); |
| 96 | 96 | ||
| 97 | struct fib6_walker_t fib6_walker_list = { | 97 | struct fib6_walker_t fib6_walker_list = { |
| 98 | .prev = &fib6_walker_list, | 98 | .prev = &fib6_walker_list, |
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c index b6c73da5ff35..f841bde30c18 100644 --- a/net/ipv6/ip6_flowlabel.c +++ b/net/ipv6/ip6_flowlabel.c | |||
| @@ -50,7 +50,7 @@ static atomic_t fl_size = ATOMIC_INIT(0); | |||
| 50 | static struct ip6_flowlabel *fl_ht[FL_HASH_MASK+1]; | 50 | static struct ip6_flowlabel *fl_ht[FL_HASH_MASK+1]; |
| 51 | 51 | ||
| 52 | static void ip6_fl_gc(unsigned long dummy); | 52 | static void ip6_fl_gc(unsigned long dummy); |
| 53 | static struct timer_list ip6_fl_gc_timer = TIMER_INITIALIZER(ip6_fl_gc, 0, 0); | 53 | static DEFINE_TIMER(ip6_fl_gc_timer, ip6_fl_gc, 0, 0); |
| 54 | 54 | ||
| 55 | /* FL hash table lock: it protects only of GC */ | 55 | /* FL hash table lock: it protects only of GC */ |
| 56 | 56 | ||
| @@ -225,16 +225,20 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions * opt_space, | |||
| 225 | struct ip6_flowlabel * fl, | 225 | struct ip6_flowlabel * fl, |
| 226 | struct ipv6_txoptions * fopt) | 226 | struct ipv6_txoptions * fopt) |
| 227 | { | 227 | { |
| 228 | struct ipv6_txoptions * fl_opt = fl->opt; | 228 | struct ipv6_txoptions * fl_opt = fl ? fl->opt : NULL; |
| 229 | 229 | ||
| 230 | if (fopt == NULL || fopt->opt_flen == 0) | 230 | if (fopt == NULL || fopt->opt_flen == 0) { |
| 231 | return fl_opt; | 231 | if (!fl_opt || !fl_opt->dst0opt || fl_opt->srcrt) |
| 232 | return fl_opt; | ||
| 233 | } | ||
| 232 | 234 | ||
| 233 | if (fl_opt != NULL) { | 235 | if (fl_opt != NULL) { |
| 234 | opt_space->hopopt = fl_opt->hopopt; | 236 | opt_space->hopopt = fl_opt->hopopt; |
| 235 | opt_space->dst0opt = fl_opt->dst0opt; | 237 | opt_space->dst0opt = fl_opt->srcrt ? fl_opt->dst0opt : NULL; |
| 236 | opt_space->srcrt = fl_opt->srcrt; | 238 | opt_space->srcrt = fl_opt->srcrt; |
| 237 | opt_space->opt_nflen = fl_opt->opt_nflen; | 239 | opt_space->opt_nflen = fl_opt->opt_nflen; |
| 240 | if (fl_opt->dst0opt && !fl_opt->srcrt) | ||
| 241 | opt_space->opt_nflen -= ipv6_optlen(fl_opt->dst0opt); | ||
| 238 | } else { | 242 | } else { |
| 239 | if (fopt->opt_nflen == 0) | 243 | if (fopt->opt_nflen == 0) |
| 240 | return fopt; | 244 | return fopt; |
| @@ -310,7 +314,7 @@ fl_create(struct in6_flowlabel_req *freq, char __user *optval, int optlen, int * | |||
| 310 | msg.msg_control = (void*)(fl->opt+1); | 314 | msg.msg_control = (void*)(fl->opt+1); |
| 311 | flowi.oif = 0; | 315 | flowi.oif = 0; |
| 312 | 316 | ||
| 313 | err = datagram_send_ctl(&msg, &flowi, fl->opt, &junk); | 317 | err = datagram_send_ctl(&msg, &flowi, fl->opt, &junk, &junk); |
| 314 | if (err) | 318 | if (err) |
| 315 | goto done; | 319 | goto done; |
| 316 | err = -EINVAL; | 320 | err = -EINVAL; |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 01ef94f7c7f1..2f589f24c093 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
| @@ -166,7 +166,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, | |||
| 166 | struct ipv6hdr *hdr; | 166 | struct ipv6hdr *hdr; |
| 167 | u8 proto = fl->proto; | 167 | u8 proto = fl->proto; |
| 168 | int seg_len = skb->len; | 168 | int seg_len = skb->len; |
| 169 | int hlimit; | 169 | int hlimit, tclass; |
| 170 | u32 mtu; | 170 | u32 mtu; |
| 171 | 171 | ||
| 172 | if (opt) { | 172 | if (opt) { |
| @@ -202,7 +202,6 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, | |||
| 202 | * Fill in the IPv6 header | 202 | * Fill in the IPv6 header |
| 203 | */ | 203 | */ |
| 204 | 204 | ||
| 205 | *(u32*)hdr = htonl(0x60000000) | fl->fl6_flowlabel; | ||
| 206 | hlimit = -1; | 205 | hlimit = -1; |
| 207 | if (np) | 206 | if (np) |
| 208 | hlimit = np->hop_limit; | 207 | hlimit = np->hop_limit; |
| @@ -211,6 +210,14 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, | |||
| 211 | if (hlimit < 0) | 210 | if (hlimit < 0) |
| 212 | hlimit = ipv6_get_hoplimit(dst->dev); | 211 | hlimit = ipv6_get_hoplimit(dst->dev); |
| 213 | 212 | ||
| 213 | tclass = -1; | ||
| 214 | if (np) | ||
| 215 | tclass = np->tclass; | ||
| 216 | if (tclass < 0) | ||
| 217 | tclass = 0; | ||
| 218 | |||
| 219 | *(u32 *)hdr = htonl(0x60000000 | (tclass << 20)) | fl->fl6_flowlabel; | ||
| 220 | |||
| 214 | hdr->payload_len = htons(seg_len); | 221 | hdr->payload_len = htons(seg_len); |
| 215 | hdr->nexthdr = proto; | 222 | hdr->nexthdr = proto; |
| 216 | hdr->hop_limit = hlimit; | 223 | hdr->hop_limit = hlimit; |
| @@ -762,10 +769,11 @@ out_err_release: | |||
| 762 | return err; | 769 | return err; |
| 763 | } | 770 | } |
| 764 | 771 | ||
| 765 | int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb), | 772 | int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, |
| 766 | void *from, int length, int transhdrlen, | 773 | int offset, int len, int odd, struct sk_buff *skb), |
| 767 | int hlimit, struct ipv6_txoptions *opt, struct flowi *fl, struct rt6_info *rt, | 774 | void *from, int length, int transhdrlen, |
| 768 | unsigned int flags) | 775 | int hlimit, int tclass, struct ipv6_txoptions *opt, struct flowi *fl, |
| 776 | struct rt6_info *rt, unsigned int flags) | ||
| 769 | { | 777 | { |
| 770 | struct inet_sock *inet = inet_sk(sk); | 778 | struct inet_sock *inet = inet_sk(sk); |
| 771 | struct ipv6_pinfo *np = inet6_sk(sk); | 779 | struct ipv6_pinfo *np = inet6_sk(sk); |
| @@ -803,6 +811,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, int offse | |||
| 803 | np->cork.rt = rt; | 811 | np->cork.rt = rt; |
| 804 | inet->cork.fl = *fl; | 812 | inet->cork.fl = *fl; |
| 805 | np->cork.hop_limit = hlimit; | 813 | np->cork.hop_limit = hlimit; |
| 814 | np->cork.tclass = tclass; | ||
| 806 | inet->cork.fragsize = mtu = dst_mtu(rt->u.dst.path); | 815 | inet->cork.fragsize = mtu = dst_mtu(rt->u.dst.path); |
| 807 | if (dst_allfrag(rt->u.dst.path)) | 816 | if (dst_allfrag(rt->u.dst.path)) |
| 808 | inet->cork.flags |= IPCORK_ALLFRAG; | 817 | inet->cork.flags |= IPCORK_ALLFRAG; |
| @@ -1084,7 +1093,8 @@ int ip6_push_pending_frames(struct sock *sk) | |||
| 1084 | 1093 | ||
| 1085 | skb->nh.ipv6h = hdr = (struct ipv6hdr*) skb_push(skb, sizeof(struct ipv6hdr)); | 1094 | skb->nh.ipv6h = hdr = (struct ipv6hdr*) skb_push(skb, sizeof(struct ipv6hdr)); |
| 1086 | 1095 | ||
| 1087 | *(u32*)hdr = fl->fl6_flowlabel | htonl(0x60000000); | 1096 | *(u32*)hdr = fl->fl6_flowlabel | |
| 1097 | htonl(0x60000000 | ((int)np->cork.tclass << 20)); | ||
| 1088 | 1098 | ||
| 1089 | if (skb->len <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN) | 1099 | if (skb->len <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN) |
| 1090 | hdr->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); | 1100 | hdr->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); |
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 09613729404c..cf94372d1af3 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
| @@ -673,11 +673,12 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 673 | 673 | ||
| 674 | if ((dst = ip6_tnl_dst_check(t)) != NULL) | 674 | if ((dst = ip6_tnl_dst_check(t)) != NULL) |
| 675 | dst_hold(dst); | 675 | dst_hold(dst); |
| 676 | else | 676 | else { |
| 677 | dst = ip6_route_output(NULL, &fl); | 677 | dst = ip6_route_output(NULL, &fl); |
| 678 | 678 | ||
| 679 | if (dst->error || xfrm_lookup(&dst, &fl, NULL, 0) < 0) | 679 | if (dst->error || xfrm_lookup(&dst, &fl, NULL, 0) < 0) |
| 680 | goto tx_err_link_failure; | 680 | goto tx_err_link_failure; |
| 681 | } | ||
| 681 | 682 | ||
| 682 | tdev = dst->dev; | 683 | tdev = dst->dev; |
| 683 | 684 | ||
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 76466af8331e..8567873d0dd8 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c | |||
| @@ -210,39 +210,139 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, | |||
| 210 | retv = 0; | 210 | retv = 0; |
| 211 | break; | 211 | break; |
| 212 | 212 | ||
| 213 | case IPV6_PKTINFO: | 213 | case IPV6_RECVPKTINFO: |
| 214 | np->rxopt.bits.rxinfo = valbool; | 214 | np->rxopt.bits.rxinfo = valbool; |
| 215 | retv = 0; | 215 | retv = 0; |
| 216 | break; | 216 | break; |
| 217 | |||
| 218 | case IPV6_2292PKTINFO: | ||
| 219 | np->rxopt.bits.rxoinfo = valbool; | ||
| 220 | retv = 0; | ||
| 221 | break; | ||
| 217 | 222 | ||
| 218 | case IPV6_HOPLIMIT: | 223 | case IPV6_RECVHOPLIMIT: |
| 219 | np->rxopt.bits.rxhlim = valbool; | 224 | np->rxopt.bits.rxhlim = valbool; |
| 220 | retv = 0; | 225 | retv = 0; |
| 221 | break; | 226 | break; |
| 222 | 227 | ||
| 223 | case IPV6_RTHDR: | 228 | case IPV6_2292HOPLIMIT: |
| 229 | np->rxopt.bits.rxohlim = valbool; | ||
| 230 | retv = 0; | ||
| 231 | break; | ||
| 232 | |||
| 233 | case IPV6_RECVRTHDR: | ||
| 224 | if (val < 0 || val > 2) | 234 | if (val < 0 || val > 2) |
| 225 | goto e_inval; | 235 | goto e_inval; |
| 226 | np->rxopt.bits.srcrt = val; | 236 | np->rxopt.bits.srcrt = val; |
| 227 | retv = 0; | 237 | retv = 0; |
| 228 | break; | 238 | break; |
| 229 | 239 | ||
| 230 | case IPV6_HOPOPTS: | 240 | case IPV6_2292RTHDR: |
| 241 | if (val < 0 || val > 2) | ||
| 242 | goto e_inval; | ||
| 243 | np->rxopt.bits.osrcrt = val; | ||
| 244 | retv = 0; | ||
| 245 | break; | ||
| 246 | |||
| 247 | case IPV6_RECVHOPOPTS: | ||
| 231 | np->rxopt.bits.hopopts = valbool; | 248 | np->rxopt.bits.hopopts = valbool; |
| 232 | retv = 0; | 249 | retv = 0; |
| 233 | break; | 250 | break; |
| 234 | 251 | ||
| 235 | case IPV6_DSTOPTS: | 252 | case IPV6_2292HOPOPTS: |
| 253 | np->rxopt.bits.ohopopts = valbool; | ||
| 254 | retv = 0; | ||
| 255 | break; | ||
| 256 | |||
| 257 | case IPV6_RECVDSTOPTS: | ||
| 236 | np->rxopt.bits.dstopts = valbool; | 258 | np->rxopt.bits.dstopts = valbool; |
| 237 | retv = 0; | 259 | retv = 0; |
| 238 | break; | 260 | break; |
| 239 | 261 | ||
| 262 | case IPV6_2292DSTOPTS: | ||
| 263 | np->rxopt.bits.odstopts = valbool; | ||
| 264 | retv = 0; | ||
| 265 | break; | ||
| 266 | |||
| 267 | case IPV6_TCLASS: | ||
| 268 | if (val < 0 || val > 0xff) | ||
| 269 | goto e_inval; | ||
| 270 | np->tclass = val; | ||
| 271 | retv = 0; | ||
| 272 | break; | ||
| 273 | |||
| 274 | case IPV6_RECVTCLASS: | ||
| 275 | np->rxopt.bits.rxtclass = valbool; | ||
| 276 | retv = 0; | ||
| 277 | break; | ||
| 278 | |||
| 240 | case IPV6_FLOWINFO: | 279 | case IPV6_FLOWINFO: |
| 241 | np->rxopt.bits.rxflow = valbool; | 280 | np->rxopt.bits.rxflow = valbool; |
| 242 | retv = 0; | 281 | retv = 0; |
| 243 | break; | 282 | break; |
| 244 | 283 | ||
| 245 | case IPV6_PKTOPTIONS: | 284 | case IPV6_HOPOPTS: |
| 285 | case IPV6_RTHDRDSTOPTS: | ||
| 286 | case IPV6_RTHDR: | ||
| 287 | case IPV6_DSTOPTS: | ||
| 288 | { | ||
| 289 | struct ipv6_txoptions *opt; | ||
| 290 | if (optlen == 0) | ||
| 291 | optval = 0; | ||
| 292 | |||
| 293 | /* hop-by-hop / destination options are privileged option */ | ||
| 294 | retv = -EPERM; | ||
| 295 | if (optname != IPV6_RTHDR && !capable(CAP_NET_RAW)) | ||
| 296 | break; | ||
| 297 | |||
| 298 | retv = -EINVAL; | ||
| 299 | if (optlen & 0x7 || optlen > 8 * 255) | ||
| 300 | break; | ||
| 301 | |||
| 302 | opt = ipv6_renew_options(sk, np->opt, optname, | ||
| 303 | (struct ipv6_opt_hdr __user *)optval, | ||
| 304 | optlen); | ||
| 305 | if (IS_ERR(opt)) { | ||
| 306 | retv = PTR_ERR(opt); | ||
| 307 | break; | ||
| 308 | } | ||
| 309 | |||
| 310 | /* routing header option needs extra check */ | ||
| 311 | if (optname == IPV6_RTHDR && opt->srcrt) { | ||
| 312 | struct ipv6_rt_hdr *rthdr = opt->srcrt; | ||
| 313 | if (rthdr->type) | ||
| 314 | goto sticky_done; | ||
| 315 | if ((rthdr->hdrlen & 1) || | ||
| 316 | (rthdr->hdrlen >> 1) != rthdr->segments_left) | ||
| 317 | goto sticky_done; | ||
| 318 | } | ||
| 319 | |||
| 320 | retv = 0; | ||
| 321 | if (sk->sk_type == SOCK_STREAM) { | ||
| 322 | if (opt) { | ||
| 323 | struct tcp_sock *tp = tcp_sk(sk); | ||
| 324 | if (!((1 << sk->sk_state) & | ||
| 325 | (TCPF_LISTEN | TCPF_CLOSE)) | ||
| 326 | && inet_sk(sk)->daddr != LOOPBACK4_IPV6) { | ||
| 327 | tp->ext_header_len = opt->opt_flen + opt->opt_nflen; | ||
| 328 | tcp_sync_mss(sk, tp->pmtu_cookie); | ||
| 329 | } | ||
| 330 | } | ||
| 331 | opt = xchg(&np->opt, opt); | ||
| 332 | sk_dst_reset(sk); | ||
| 333 | } else { | ||
| 334 | write_lock(&sk->sk_dst_lock); | ||
| 335 | opt = xchg(&np->opt, opt); | ||
| 336 | write_unlock(&sk->sk_dst_lock); | ||
| 337 | sk_dst_reset(sk); | ||
| 338 | } | ||
| 339 | sticky_done: | ||
| 340 | if (opt) | ||
| 341 | sock_kfree_s(sk, opt, opt->tot_len); | ||
| 342 | break; | ||
| 343 | } | ||
| 344 | |||
| 345 | case IPV6_2292PKTOPTIONS: | ||
| 246 | { | 346 | { |
| 247 | struct ipv6_txoptions *opt = NULL; | 347 | struct ipv6_txoptions *opt = NULL; |
| 248 | struct msghdr msg; | 348 | struct msghdr msg; |
| @@ -276,7 +376,7 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, | |||
| 276 | msg.msg_controllen = optlen; | 376 | msg.msg_controllen = optlen; |
| 277 | msg.msg_control = (void*)(opt+1); | 377 | msg.msg_control = (void*)(opt+1); |
| 278 | 378 | ||
| 279 | retv = datagram_send_ctl(&msg, &fl, opt, &junk); | 379 | retv = datagram_send_ctl(&msg, &fl, opt, &junk, &junk); |
| 280 | if (retv) | 380 | if (retv) |
| 281 | goto done; | 381 | goto done; |
| 282 | update: | 382 | update: |
| @@ -529,6 +629,17 @@ e_inval: | |||
| 529 | return -EINVAL; | 629 | return -EINVAL; |
| 530 | } | 630 | } |
| 531 | 631 | ||
| 632 | int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_opt_hdr *hdr, | ||
| 633 | char __user *optval, int len) | ||
| 634 | { | ||
| 635 | if (!hdr) | ||
| 636 | return 0; | ||
| 637 | len = min_t(int, len, ipv6_optlen(hdr)); | ||
| 638 | if (copy_to_user(optval, hdr, ipv6_optlen(hdr))) | ||
| 639 | return -EFAULT; | ||
| 640 | return len; | ||
| 641 | } | ||
| 642 | |||
| 532 | int ipv6_getsockopt(struct sock *sk, int level, int optname, | 643 | int ipv6_getsockopt(struct sock *sk, int level, int optname, |
| 533 | char __user *optval, int __user *optlen) | 644 | char __user *optval, int __user *optlen) |
| 534 | { | 645 | { |
| @@ -567,7 +678,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, | |||
| 567 | return err; | 678 | return err; |
| 568 | } | 679 | } |
| 569 | 680 | ||
| 570 | case IPV6_PKTOPTIONS: | 681 | case IPV6_2292PKTOPTIONS: |
| 571 | { | 682 | { |
| 572 | struct msghdr msg; | 683 | struct msghdr msg; |
| 573 | struct sk_buff *skb; | 684 | struct sk_buff *skb; |
| @@ -601,6 +712,16 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, | |||
| 601 | int hlim = np->mcast_hops; | 712 | int hlim = np->mcast_hops; |
| 602 | put_cmsg(&msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim); | 713 | put_cmsg(&msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim); |
| 603 | } | 714 | } |
| 715 | if (np->rxopt.bits.rxoinfo) { | ||
| 716 | struct in6_pktinfo src_info; | ||
| 717 | src_info.ipi6_ifindex = np->mcast_oif; | ||
| 718 | ipv6_addr_copy(&src_info.ipi6_addr, &np->daddr); | ||
| 719 | put_cmsg(&msg, SOL_IPV6, IPV6_2292PKTINFO, sizeof(src_info), &src_info); | ||
| 720 | } | ||
| 721 | if (np->rxopt.bits.rxohlim) { | ||
| 722 | int hlim = np->mcast_hops; | ||
| 723 | put_cmsg(&msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim); | ||
| 724 | } | ||
| 604 | } | 725 | } |
| 605 | len -= msg.msg_controllen; | 726 | len -= msg.msg_controllen; |
| 606 | return put_user(len, optlen); | 727 | return put_user(len, optlen); |
| @@ -625,26 +746,67 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, | |||
| 625 | val = np->ipv6only; | 746 | val = np->ipv6only; |
| 626 | break; | 747 | break; |
| 627 | 748 | ||
| 628 | case IPV6_PKTINFO: | 749 | case IPV6_RECVPKTINFO: |
| 629 | val = np->rxopt.bits.rxinfo; | 750 | val = np->rxopt.bits.rxinfo; |
| 630 | break; | 751 | break; |
| 631 | 752 | ||
| 632 | case IPV6_HOPLIMIT: | 753 | case IPV6_2292PKTINFO: |
| 754 | val = np->rxopt.bits.rxoinfo; | ||
| 755 | break; | ||
| 756 | |||
| 757 | case IPV6_RECVHOPLIMIT: | ||
| 633 | val = np->rxopt.bits.rxhlim; | 758 | val = np->rxopt.bits.rxhlim; |
| 634 | break; | 759 | break; |
| 635 | 760 | ||
| 636 | case IPV6_RTHDR: | 761 | case IPV6_2292HOPLIMIT: |
| 762 | val = np->rxopt.bits.rxohlim; | ||
| 763 | break; | ||
| 764 | |||
| 765 | case IPV6_RECVRTHDR: | ||
| 637 | val = np->rxopt.bits.srcrt; | 766 | val = np->rxopt.bits.srcrt; |
| 638 | break; | 767 | break; |
| 639 | 768 | ||
| 769 | case IPV6_2292RTHDR: | ||
| 770 | val = np->rxopt.bits.osrcrt; | ||
| 771 | break; | ||
| 772 | |||
| 640 | case IPV6_HOPOPTS: | 773 | case IPV6_HOPOPTS: |
| 774 | case IPV6_RTHDRDSTOPTS: | ||
| 775 | case IPV6_RTHDR: | ||
| 776 | case IPV6_DSTOPTS: | ||
| 777 | { | ||
| 778 | |||
| 779 | lock_sock(sk); | ||
| 780 | len = ipv6_getsockopt_sticky(sk, np->opt->hopopt, | ||
| 781 | optval, len); | ||
| 782 | release_sock(sk); | ||
| 783 | return put_user(len, optlen); | ||
| 784 | } | ||
| 785 | |||
| 786 | case IPV6_RECVHOPOPTS: | ||
| 641 | val = np->rxopt.bits.hopopts; | 787 | val = np->rxopt.bits.hopopts; |
| 642 | break; | 788 | break; |
| 643 | 789 | ||
| 644 | case IPV6_DSTOPTS: | 790 | case IPV6_2292HOPOPTS: |
| 791 | val = np->rxopt.bits.ohopopts; | ||
| 792 | break; | ||
| 793 | |||
| 794 | case IPV6_RECVDSTOPTS: | ||
| 645 | val = np->rxopt.bits.dstopts; | 795 | val = np->rxopt.bits.dstopts; |
| 646 | break; | 796 | break; |
| 647 | 797 | ||
| 798 | case IPV6_2292DSTOPTS: | ||
| 799 | val = np->rxopt.bits.odstopts; | ||
| 800 | break; | ||
| 801 | |||
| 802 | case IPV6_TCLASS: | ||
| 803 | val = np->tclass; | ||
| 804 | break; | ||
| 805 | |||
| 806 | case IPV6_RECVTCLASS: | ||
| 807 | val = np->rxopt.bits.rxtclass; | ||
| 808 | break; | ||
| 809 | |||
| 648 | case IPV6_FLOWINFO: | 810 | case IPV6_FLOWINFO: |
| 649 | val = np->rxopt.bits.rxflow; | 811 | val = np->rxopt.bits.rxflow; |
| 650 | break; | 812 | break; |
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index a7eae30f4554..555a31347eda 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
| @@ -447,10 +447,8 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh, | |||
| 447 | return; | 447 | return; |
| 448 | 448 | ||
| 449 | err = xfrm_lookup(&dst, &fl, NULL, 0); | 449 | err = xfrm_lookup(&dst, &fl, NULL, 0); |
| 450 | if (err < 0) { | 450 | if (err < 0) |
| 451 | dst_release(dst); | ||
| 452 | return; | 451 | return; |
| 453 | } | ||
| 454 | 452 | ||
| 455 | if (inc_opt) { | 453 | if (inc_opt) { |
| 456 | if (dev->addr_len) | 454 | if (dev->addr_len) |
| @@ -539,10 +537,8 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh, | |||
| 539 | return; | 537 | return; |
| 540 | 538 | ||
| 541 | err = xfrm_lookup(&dst, &fl, NULL, 0); | 539 | err = xfrm_lookup(&dst, &fl, NULL, 0); |
| 542 | if (err < 0) { | 540 | if (err < 0) |
| 543 | dst_release(dst); | ||
| 544 | return; | 541 | return; |
| 545 | } | ||
| 546 | 542 | ||
| 547 | len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr); | 543 | len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr); |
| 548 | send_llinfo = dev->addr_len && !ipv6_addr_any(saddr); | 544 | send_llinfo = dev->addr_len && !ipv6_addr_any(saddr); |
| @@ -616,10 +612,8 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr, | |||
| 616 | return; | 612 | return; |
| 617 | 613 | ||
| 618 | err = xfrm_lookup(&dst, &fl, NULL, 0); | 614 | err = xfrm_lookup(&dst, &fl, NULL, 0); |
| 619 | if (err < 0) { | 615 | if (err < 0) |
| 620 | dst_release(dst); | ||
| 621 | return; | 616 | return; |
| 622 | } | ||
| 623 | 617 | ||
| 624 | len = sizeof(struct icmp6hdr); | 618 | len = sizeof(struct icmp6hdr); |
| 625 | if (dev->addr_len) | 619 | if (dev->addr_len) |
| @@ -1353,10 +1347,8 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh, | |||
| 1353 | return; | 1347 | return; |
| 1354 | 1348 | ||
| 1355 | err = xfrm_lookup(&dst, &fl, NULL, 0); | 1349 | err = xfrm_lookup(&dst, &fl, NULL, 0); |
| 1356 | if (err) { | 1350 | if (err) |
| 1357 | dst_release(dst); | ||
| 1358 | return; | 1351 | return; |
| 1359 | } | ||
| 1360 | 1352 | ||
| 1361 | rt = (struct rt6_info *) dst; | 1353 | rt = (struct rt6_info *) dst; |
| 1362 | 1354 | ||
diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c index 14316c3ebde4..b03e87adca93 100644 --- a/net/ipv6/netfilter/ip6t_REJECT.c +++ b/net/ipv6/netfilter/ip6t_REJECT.c | |||
| @@ -100,11 +100,8 @@ static void send_reset(struct sk_buff *oldskb) | |||
| 100 | dst = ip6_route_output(NULL, &fl); | 100 | dst = ip6_route_output(NULL, &fl); |
| 101 | if (dst == NULL) | 101 | if (dst == NULL) |
| 102 | return; | 102 | return; |
| 103 | if (dst->error || | 103 | if (dst->error || xfrm_lookup(&dst, &fl, NULL, 0)) |
| 104 | xfrm_lookup(&dst, &fl, NULL, 0)) { | ||
| 105 | dst_release(dst); | ||
| 106 | return; | 104 | return; |
| 107 | } | ||
| 108 | 105 | ||
| 109 | hh_len = (dst->dev->hard_header_len + 15)&~15; | 106 | hh_len = (dst->dev->hard_header_len + 15)&~15; |
| 110 | nskb = alloc_skb(hh_len + 15 + dst->header_len + sizeof(struct ipv6hdr) | 107 | nskb = alloc_skb(hh_len + 15 + dst->header_len + sizeof(struct ipv6hdr) |
diff --git a/net/ipv6/netfilter/ip6t_owner.c b/net/ipv6/netfilter/ip6t_owner.c index 9b91decbfddb..4de4cdad4b7d 100644 --- a/net/ipv6/netfilter/ip6t_owner.c +++ b/net/ipv6/netfilter/ip6t_owner.c | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
| 12 | #include <linux/skbuff.h> | 12 | #include <linux/skbuff.h> |
| 13 | #include <linux/file.h> | 13 | #include <linux/file.h> |
| 14 | #include <linux/rcupdate.h> | ||
| 14 | #include <net/sock.h> | 15 | #include <net/sock.h> |
| 15 | 16 | ||
| 16 | #include <linux/netfilter_ipv6/ip6t_owner.h> | 17 | #include <linux/netfilter_ipv6/ip6t_owner.h> |
diff --git a/net/ipv6/netfilter/ip6t_rt.c b/net/ipv6/netfilter/ip6t_rt.c index a9526b773d28..2bb670037df3 100644 --- a/net/ipv6/netfilter/ip6t_rt.c +++ b/net/ipv6/netfilter/ip6t_rt.c | |||
| @@ -161,8 +161,8 @@ match(const struct sk_buff *skb, | |||
| 161 | ((rtinfo->hdrlen == hdrlen) ^ | 161 | ((rtinfo->hdrlen == hdrlen) ^ |
| 162 | !!(rtinfo->invflags & IP6T_RT_INV_LEN)))); | 162 | !!(rtinfo->invflags & IP6T_RT_INV_LEN)))); |
| 163 | DEBUGP("res %02X %02X %02X ", | 163 | DEBUGP("res %02X %02X %02X ", |
| 164 | (rtinfo->flags & IP6T_RT_RES), ((struct rt0_hdr *)rh)->bitmap, | 164 | (rtinfo->flags & IP6T_RT_RES), ((struct rt0_hdr *)rh)->reserved, |
| 165 | !((rtinfo->flags & IP6T_RT_RES) && (((struct rt0_hdr *)rh)->bitmap))); | 165 | !((rtinfo->flags & IP6T_RT_RES) && (((struct rt0_hdr *)rh)->reserved))); |
| 166 | 166 | ||
| 167 | ret = (rh != NULL) | 167 | ret = (rh != NULL) |
| 168 | && | 168 | && |
| @@ -179,12 +179,12 @@ match(const struct sk_buff *skb, | |||
| 179 | !!(rtinfo->invflags & IP6T_RT_INV_TYP))); | 179 | !!(rtinfo->invflags & IP6T_RT_INV_TYP))); |
| 180 | 180 | ||
| 181 | if (ret && (rtinfo->flags & IP6T_RT_RES)) { | 181 | if (ret && (rtinfo->flags & IP6T_RT_RES)) { |
| 182 | u_int32_t *bp, _bitmap; | 182 | u_int32_t *rp, _reserved; |
| 183 | bp = skb_header_pointer(skb, | 183 | rp = skb_header_pointer(skb, |
| 184 | ptr + offsetof(struct rt0_hdr, bitmap), | 184 | ptr + offsetof(struct rt0_hdr, reserved), |
| 185 | sizeof(_bitmap), &_bitmap); | 185 | sizeof(_reserved), &_reserved); |
| 186 | 186 | ||
| 187 | ret = (*bp == 0); | 187 | ret = (*rp == 0); |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | DEBUGP("#%d ",rtinfo->addrnr); | 190 | DEBUGP("#%d ",rtinfo->addrnr); |
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index ed3a76b30fd9..5aa3691c578d 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c | |||
| @@ -655,6 +655,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
| 655 | struct flowi fl; | 655 | struct flowi fl; |
| 656 | int addr_len = msg->msg_namelen; | 656 | int addr_len = msg->msg_namelen; |
| 657 | int hlimit = -1; | 657 | int hlimit = -1; |
| 658 | int tclass = -1; | ||
| 658 | u16 proto; | 659 | u16 proto; |
| 659 | int err; | 660 | int err; |
| 660 | 661 | ||
| @@ -740,7 +741,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
| 740 | memset(opt, 0, sizeof(struct ipv6_txoptions)); | 741 | memset(opt, 0, sizeof(struct ipv6_txoptions)); |
| 741 | opt->tot_len = sizeof(struct ipv6_txoptions); | 742 | opt->tot_len = sizeof(struct ipv6_txoptions); |
| 742 | 743 | ||
| 743 | err = datagram_send_ctl(msg, &fl, opt, &hlimit); | 744 | err = datagram_send_ctl(msg, &fl, opt, &hlimit, &tclass); |
| 744 | if (err < 0) { | 745 | if (err < 0) { |
| 745 | fl6_sock_release(flowlabel); | 746 | fl6_sock_release(flowlabel); |
| 746 | return err; | 747 | return err; |
| @@ -755,8 +756,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
| 755 | } | 756 | } |
| 756 | if (opt == NULL) | 757 | if (opt == NULL) |
| 757 | opt = np->opt; | 758 | opt = np->opt; |
| 758 | if (flowlabel) | 759 | opt = fl6_merge_options(&opt_space, flowlabel, opt); |
| 759 | opt = fl6_merge_options(&opt_space, flowlabel, opt); | ||
| 760 | 760 | ||
| 761 | fl.proto = proto; | 761 | fl.proto = proto; |
| 762 | rawv6_probe_proto_opt(&fl, msg); | 762 | rawv6_probe_proto_opt(&fl, msg); |
| @@ -782,10 +782,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
| 782 | if (final_p) | 782 | if (final_p) |
| 783 | ipv6_addr_copy(&fl.fl6_dst, final_p); | 783 | ipv6_addr_copy(&fl.fl6_dst, final_p); |
| 784 | 784 | ||
| 785 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { | 785 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) |
| 786 | dst_release(dst); | ||
| 787 | goto out; | 786 | goto out; |
| 788 | } | ||
| 789 | 787 | ||
| 790 | if (hlimit < 0) { | 788 | if (hlimit < 0) { |
| 791 | if (ipv6_addr_is_multicast(&fl.fl6_dst)) | 789 | if (ipv6_addr_is_multicast(&fl.fl6_dst)) |
| @@ -798,6 +796,12 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
| 798 | hlimit = ipv6_get_hoplimit(dst->dev); | 796 | hlimit = ipv6_get_hoplimit(dst->dev); |
| 799 | } | 797 | } |
| 800 | 798 | ||
| 799 | if (tclass < 0) { | ||
| 800 | tclass = np->cork.tclass; | ||
| 801 | if (tclass < 0) | ||
| 802 | tclass = 0; | ||
| 803 | } | ||
| 804 | |||
| 801 | if (msg->msg_flags&MSG_CONFIRM) | 805 | if (msg->msg_flags&MSG_CONFIRM) |
| 802 | goto do_confirm; | 806 | goto do_confirm; |
| 803 | 807 | ||
| @@ -806,8 +810,9 @@ back_from_confirm: | |||
| 806 | err = rawv6_send_hdrinc(sk, msg->msg_iov, len, &fl, (struct rt6_info*)dst, msg->msg_flags); | 810 | err = rawv6_send_hdrinc(sk, msg->msg_iov, len, &fl, (struct rt6_info*)dst, msg->msg_flags); |
| 807 | } else { | 811 | } else { |
| 808 | lock_sock(sk); | 812 | lock_sock(sk); |
| 809 | err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, len, 0, | 813 | err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, |
| 810 | hlimit, opt, &fl, (struct rt6_info*)dst, msg->msg_flags); | 814 | len, 0, hlimit, tclass, opt, &fl, (struct rt6_info*)dst, |
| 815 | msg->msg_flags); | ||
| 811 | 816 | ||
| 812 | if (err) | 817 | if (err) |
| 813 | ip6_flush_pending_frames(sk); | 818 | ip6_flush_pending_frames(sk); |
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 9d9e04344c77..e4fe9ee484dd 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
| @@ -479,12 +479,9 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, | |||
| 479 | /* Point into the IP datagram 'data' part. */ | 479 | /* Point into the IP datagram 'data' part. */ |
| 480 | if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data)) | 480 | if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data)) |
| 481 | goto err; | 481 | goto err; |
| 482 | if (end-offset < skb->len) { | 482 | |
| 483 | if (pskb_trim(skb, end - offset)) | 483 | if (pskb_trim_rcsum(skb, end - offset)) |
| 484 | goto err; | 484 | goto err; |
| 485 | if (skb->ip_summed != CHECKSUM_UNNECESSARY) | ||
| 486 | skb->ip_summed = CHECKSUM_NONE; | ||
| 487 | } | ||
| 488 | 485 | ||
| 489 | /* Find out which fragments are in front and at the back of us | 486 | /* Find out which fragments are in front and at the back of us |
| 490 | * in the chain of fragments so far. We must know where to put | 487 | * in the chain of fragments so far. We must know where to put |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 794734f1d230..80643e6b346b 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
| @@ -632,10 +632,8 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
| 632 | if (final_p) | 632 | if (final_p) |
| 633 | ipv6_addr_copy(&fl.fl6_dst, final_p); | 633 | ipv6_addr_copy(&fl.fl6_dst, final_p); |
| 634 | 634 | ||
| 635 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { | 635 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) |
| 636 | dst_release(dst); | ||
| 637 | goto failure; | 636 | goto failure; |
| 638 | } | ||
| 639 | 637 | ||
| 640 | if (saddr == NULL) { | 638 | if (saddr == NULL) { |
| 641 | saddr = &fl.fl6_src; | 639 | saddr = &fl.fl6_src; |
| @@ -849,7 +847,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req, | |||
| 849 | if (dst == NULL) { | 847 | if (dst == NULL) { |
| 850 | opt = np->opt; | 848 | opt = np->opt; |
| 851 | if (opt == NULL && | 849 | if (opt == NULL && |
| 852 | np->rxopt.bits.srcrt == 2 && | 850 | np->rxopt.bits.osrcrt == 2 && |
| 853 | treq->pktopts) { | 851 | treq->pktopts) { |
| 854 | struct sk_buff *pktopts = treq->pktopts; | 852 | struct sk_buff *pktopts = treq->pktopts; |
| 855 | struct inet6_skb_parm *rxopt = IP6CB(pktopts); | 853 | struct inet6_skb_parm *rxopt = IP6CB(pktopts); |
| @@ -888,7 +886,6 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req, | |||
| 888 | } | 886 | } |
| 889 | 887 | ||
| 890 | done: | 888 | done: |
| 891 | dst_release(dst); | ||
| 892 | if (opt && opt != np->opt) | 889 | if (opt && opt != np->opt) |
| 893 | sock_kfree_s(sk, opt, opt->tot_len); | 890 | sock_kfree_s(sk, opt, opt->tot_len); |
| 894 | return err; | 891 | return err; |
| @@ -915,11 +912,10 @@ static int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb) | |||
| 915 | struct inet6_skb_parm *opt = IP6CB(skb); | 912 | struct inet6_skb_parm *opt = IP6CB(skb); |
| 916 | 913 | ||
| 917 | if (np->rxopt.all) { | 914 | if (np->rxopt.all) { |
| 918 | if ((opt->hop && np->rxopt.bits.hopopts) || | 915 | if ((opt->hop && (np->rxopt.bits.hopopts || np->rxopt.bits.ohopopts)) || |
| 919 | ((IPV6_FLOWINFO_MASK&*(u32*)skb->nh.raw) && | 916 | ((IPV6_FLOWINFO_MASK & *(u32*)skb->nh.raw) && np->rxopt.bits.rxflow) || |
| 920 | np->rxopt.bits.rxflow) || | 917 | (opt->srcrt && (np->rxopt.bits.srcrt || np->rxopt.bits.osrcrt)) || |
| 921 | (opt->srcrt && np->rxopt.bits.srcrt) || | 918 | ((opt->dst1 || opt->dst0) && (np->rxopt.bits.dstopts || np->rxopt.bits.odstopts))) |
| 922 | ((opt->dst1 || opt->dst0) && np->rxopt.bits.dstopts)) | ||
| 923 | return 1; | 919 | return 1; |
| 924 | } | 920 | } |
| 925 | return 0; | 921 | return 0; |
| @@ -1001,10 +997,8 @@ static void tcp_v6_send_reset(struct sk_buff *skb) | |||
| 1001 | /* sk = NULL, but it is safe for now. RST socket required. */ | 997 | /* sk = NULL, but it is safe for now. RST socket required. */ |
| 1002 | if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) { | 998 | if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) { |
| 1003 | 999 | ||
| 1004 | if ((xfrm_lookup(&buff->dst, &fl, NULL, 0)) < 0) { | 1000 | if ((xfrm_lookup(&buff->dst, &fl, NULL, 0)) < 0) |
| 1005 | dst_release(buff->dst); | ||
| 1006 | return; | 1001 | return; |
| 1007 | } | ||
| 1008 | 1002 | ||
| 1009 | ip6_xmit(NULL, buff, &fl, NULL, 0); | 1003 | ip6_xmit(NULL, buff, &fl, NULL, 0); |
| 1010 | TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); | 1004 | TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); |
| @@ -1068,10 +1062,8 @@ static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 | |||
| 1068 | fl.fl_ip_sport = t1->source; | 1062 | fl.fl_ip_sport = t1->source; |
| 1069 | 1063 | ||
| 1070 | if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) { | 1064 | if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) { |
| 1071 | if ((xfrm_lookup(&buff->dst, &fl, NULL, 0)) < 0) { | 1065 | if ((xfrm_lookup(&buff->dst, &fl, NULL, 0)) < 0) |
| 1072 | dst_release(buff->dst); | ||
| 1073 | return; | 1066 | return; |
| 1074 | } | ||
| 1075 | ip6_xmit(NULL, buff, &fl, NULL, 0); | 1067 | ip6_xmit(NULL, buff, &fl, NULL, 0); |
| 1076 | TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); | 1068 | TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); |
| 1077 | return; | 1069 | return; |
| @@ -1190,8 +1182,8 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) | |||
| 1190 | TCP_ECN_create_request(req, skb->h.th); | 1182 | TCP_ECN_create_request(req, skb->h.th); |
| 1191 | treq->pktopts = NULL; | 1183 | treq->pktopts = NULL; |
| 1192 | if (ipv6_opt_accepted(sk, skb) || | 1184 | if (ipv6_opt_accepted(sk, skb) || |
| 1193 | np->rxopt.bits.rxinfo || | 1185 | np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo || |
| 1194 | np->rxopt.bits.rxhlim) { | 1186 | np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) { |
| 1195 | atomic_inc(&skb->users); | 1187 | atomic_inc(&skb->users); |
| 1196 | treq->pktopts = skb; | 1188 | treq->pktopts = skb; |
| 1197 | } | 1189 | } |
| @@ -1288,7 +1280,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
| 1288 | if (sk_acceptq_is_full(sk)) | 1280 | if (sk_acceptq_is_full(sk)) |
| 1289 | goto out_overflow; | 1281 | goto out_overflow; |
| 1290 | 1282 | ||
| 1291 | if (np->rxopt.bits.srcrt == 2 && | 1283 | if (np->rxopt.bits.osrcrt == 2 && |
| 1292 | opt == NULL && treq->pktopts) { | 1284 | opt == NULL && treq->pktopts) { |
| 1293 | struct inet6_skb_parm *rxopt = IP6CB(treq->pktopts); | 1285 | struct inet6_skb_parm *rxopt = IP6CB(treq->pktopts); |
| 1294 | if (rxopt->srcrt) | 1286 | if (rxopt->srcrt) |
| @@ -1544,9 +1536,9 @@ ipv6_pktoptions: | |||
| 1544 | tp = tcp_sk(sk); | 1536 | tp = tcp_sk(sk); |
| 1545 | if (TCP_SKB_CB(opt_skb)->end_seq == tp->rcv_nxt && | 1537 | if (TCP_SKB_CB(opt_skb)->end_seq == tp->rcv_nxt && |
| 1546 | !((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) { | 1538 | !((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) { |
| 1547 | if (np->rxopt.bits.rxinfo) | 1539 | if (np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo) |
| 1548 | np->mcast_oif = inet6_iif(opt_skb); | 1540 | np->mcast_oif = inet6_iif(opt_skb); |
| 1549 | if (np->rxopt.bits.rxhlim) | 1541 | if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) |
| 1550 | np->mcast_hops = opt_skb->nh.ipv6h->hop_limit; | 1542 | np->mcast_hops = opt_skb->nh.ipv6h->hop_limit; |
| 1551 | if (ipv6_opt_accepted(sk, opt_skb)) { | 1543 | if (ipv6_opt_accepted(sk, opt_skb)) { |
| 1552 | skb_set_owner_r(opt_skb, sk); | 1544 | skb_set_owner_r(opt_skb, sk); |
| @@ -1734,7 +1726,6 @@ static int tcp_v6_rebuild_header(struct sock *sk) | |||
| 1734 | 1726 | ||
| 1735 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { | 1727 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { |
| 1736 | sk->sk_err_soft = -err; | 1728 | sk->sk_err_soft = -err; |
| 1737 | dst_release(dst); | ||
| 1738 | return err; | 1729 | return err; |
| 1739 | } | 1730 | } |
| 1740 | 1731 | ||
| @@ -1787,7 +1778,6 @@ static int tcp_v6_xmit(struct sk_buff *skb, int ipfragok) | |||
| 1787 | 1778 | ||
| 1788 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { | 1779 | if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { |
| 1789 | sk->sk_route_caps = 0; | 1780 | sk->sk_route_caps = 0; |
| 1790 | dst_release(dst); | ||
| 1791 | return err; | 1781 | return err; |
| 1792 | } | 1782 | } |
| 1793 | 1783 | ||
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 390d750449ce..69b146843a20 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
| @@ -483,7 +483,7 @@ static int udpv6_rcv(struct sk_buff **pskb, unsigned int *nhoffp) | |||
| 483 | } | 483 | } |
| 484 | 484 | ||
| 485 | if (ulen < skb->len) { | 485 | if (ulen < skb->len) { |
| 486 | if (__pskb_trim(skb, ulen)) | 486 | if (pskb_trim_rcsum(skb, ulen)) |
| 487 | goto discard; | 487 | goto discard; |
| 488 | saddr = &skb->nh.ipv6h->saddr; | 488 | saddr = &skb->nh.ipv6h->saddr; |
| 489 | daddr = &skb->nh.ipv6h->daddr; | 489 | daddr = &skb->nh.ipv6h->daddr; |
| @@ -637,6 +637,7 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
| 637 | int addr_len = msg->msg_namelen; | 637 | int addr_len = msg->msg_namelen; |
| 638 | int ulen = len; | 638 | int ulen = len; |
| 639 | int hlimit = -1; | 639 | int hlimit = -1; |
| 640 | int tclass = -1; | ||
| 640 | int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; | 641 | int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; |
| 641 | int err; | 642 | int err; |
| 642 | 643 | ||
| @@ -758,7 +759,7 @@ do_udp_sendmsg: | |||
| 758 | memset(opt, 0, sizeof(struct ipv6_txoptions)); | 759 | memset(opt, 0, sizeof(struct ipv6_txoptions)); |
| 759 | opt->tot_len = sizeof(*opt); | 760 | opt->tot_len = sizeof(*opt); |
| 760 | 761 | ||
| 761 | err = datagram_send_ctl(msg, fl, opt, &hlimit); | 762 | err = datagram_send_ctl(msg, fl, opt, &hlimit, &tclass); |
| 762 | if (err < 0) { | 763 | if (err < 0) { |
| 763 | fl6_sock_release(flowlabel); | 764 | fl6_sock_release(flowlabel); |
| 764 | return err; | 765 | return err; |
| @@ -773,8 +774,7 @@ do_udp_sendmsg: | |||
| 773 | } | 774 | } |
| 774 | if (opt == NULL) | 775 | if (opt == NULL) |
| 775 | opt = np->opt; | 776 | opt = np->opt; |
| 776 | if (flowlabel) | 777 | opt = fl6_merge_options(&opt_space, flowlabel, opt); |
| 777 | opt = fl6_merge_options(&opt_space, flowlabel, opt); | ||
| 778 | 778 | ||
| 779 | fl->proto = IPPROTO_UDP; | 779 | fl->proto = IPPROTO_UDP; |
| 780 | ipv6_addr_copy(&fl->fl6_dst, daddr); | 780 | ipv6_addr_copy(&fl->fl6_dst, daddr); |
| @@ -799,10 +799,8 @@ do_udp_sendmsg: | |||
| 799 | if (final_p) | 799 | if (final_p) |
| 800 | ipv6_addr_copy(&fl->fl6_dst, final_p); | 800 | ipv6_addr_copy(&fl->fl6_dst, final_p); |
| 801 | 801 | ||
| 802 | if ((err = xfrm_lookup(&dst, fl, sk, 0)) < 0) { | 802 | if ((err = xfrm_lookup(&dst, fl, sk, 0)) < 0) |
| 803 | dst_release(dst); | ||
| 804 | goto out; | 803 | goto out; |
| 805 | } | ||
| 806 | 804 | ||
| 807 | if (hlimit < 0) { | 805 | if (hlimit < 0) { |
| 808 | if (ipv6_addr_is_multicast(&fl->fl6_dst)) | 806 | if (ipv6_addr_is_multicast(&fl->fl6_dst)) |
| @@ -815,6 +813,12 @@ do_udp_sendmsg: | |||
| 815 | hlimit = ipv6_get_hoplimit(dst->dev); | 813 | hlimit = ipv6_get_hoplimit(dst->dev); |
| 816 | } | 814 | } |
| 817 | 815 | ||
| 816 | if (tclass < 0) { | ||
| 817 | tclass = np->tclass; | ||
| 818 | if (tclass < 0) | ||
| 819 | tclass = 0; | ||
| 820 | } | ||
| 821 | |||
| 818 | if (msg->msg_flags&MSG_CONFIRM) | 822 | if (msg->msg_flags&MSG_CONFIRM) |
| 819 | goto do_confirm; | 823 | goto do_confirm; |
| 820 | back_from_confirm: | 824 | back_from_confirm: |
| @@ -834,9 +838,10 @@ back_from_confirm: | |||
| 834 | 838 | ||
| 835 | do_append_data: | 839 | do_append_data: |
| 836 | up->len += ulen; | 840 | up->len += ulen; |
| 837 | err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, ulen, sizeof(struct udphdr), | 841 | err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, ulen, |
| 838 | hlimit, opt, fl, (struct rt6_info*)dst, | 842 | sizeof(struct udphdr), hlimit, tclass, opt, fl, |
| 839 | corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags); | 843 | (struct rt6_info*)dst, |
| 844 | corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags); | ||
| 840 | if (err) | 845 | if (err) |
| 841 | udp_v6_flush_pending_frames(sk); | 846 | udp_v6_flush_pending_frames(sk); |
| 842 | else if (!corkreq) | 847 | else if (!corkreq) |
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) | |||
| 567 | self->tty = NULL; | 567 | self->tty = NULL; |
| 568 | 568 | ||
| 569 | if (self->blocked_open) { | 569 | if (self->blocked_open) { |
| 570 | if (self->close_delay) { | 570 | if (self->close_delay) |
| 571 | current->state = TASK_INTERRUPTIBLE; | 571 | schedule_timeout_interruptible(self->close_delay); |
| 572 | schedule_timeout(self->close_delay); | ||
| 573 | } | ||
| 574 | wake_up_interruptible(&self->open_wait); | 572 | wake_up_interruptible(&self->open_wait); |
| 575 | } | 573 | } |
| 576 | 574 | ||
| @@ -863,8 +861,7 @@ static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout) | |||
| 863 | spin_lock_irqsave(&self->spinlock, flags); | 861 | spin_lock_irqsave(&self->spinlock, flags); |
| 864 | while (self->tx_skb && self->tx_skb->len) { | 862 | while (self->tx_skb && self->tx_skb->len) { |
| 865 | spin_unlock_irqrestore(&self->spinlock, flags); | 863 | spin_unlock_irqrestore(&self->spinlock, flags); |
| 866 | current->state = TASK_INTERRUPTIBLE; | 864 | schedule_timeout_interruptible(poll_time); |
| 867 | schedule_timeout(poll_time); | ||
| 868 | spin_lock_irqsave(&self->spinlock, flags); | 865 | spin_lock_irqsave(&self->spinlock, flags); |
| 869 | if (signal_pending(current)) | 866 | if (signal_pending(current)) |
| 870 | break; | 867 | break; |
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index f4578c759ffc..e5d82d711cae 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; | |||
| 56 | int sysctl_netrom_transport_no_activity_timeout = NR_DEFAULT_IDLE; | 56 | int sysctl_netrom_transport_no_activity_timeout = NR_DEFAULT_IDLE; |
| 57 | int sysctl_netrom_routing_control = NR_DEFAULT_ROUTING; | 57 | int sysctl_netrom_routing_control = NR_DEFAULT_ROUTING; |
| 58 | int sysctl_netrom_link_fails_count = NR_DEFAULT_FAILS; | 58 | int sysctl_netrom_link_fails_count = NR_DEFAULT_FAILS; |
| 59 | int sysctl_netrom_reset_circuit = NR_DEFAULT_RESET; | ||
| 59 | 60 | ||
| 60 | static unsigned short circuit = 0x101; | 61 | static unsigned short circuit = 0x101; |
| 61 | 62 | ||
| @@ -908,17 +909,17 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev) | |||
| 908 | if (frametype != NR_CONNREQ) { | 909 | if (frametype != NR_CONNREQ) { |
| 909 | /* | 910 | /* |
| 910 | * Here it would be nice to be able to send a reset but | 911 | * Here it would be nice to be able to send a reset but |
| 911 | * NET/ROM doesn't have one. The following hack would | 912 | * NET/ROM doesn't have one. We've tried to extend the protocol |
| 912 | * have been a way to extend the protocol but apparently | 913 | * by sending NR_CONNACK | NR_CHOKE_FLAGS replies but that |
| 913 | * it kills BPQ boxes... :-( | 914 | * apparently kills BPQ boxes... :-( |
| 915 | * So now we try to follow the established behaviour of | ||
| 916 | * G8PZT's Xrouter which is sending packets with command type 7 | ||
| 917 | * as an extension of the protocol. | ||
| 914 | */ | 918 | */ |
| 915 | #if 0 | 919 | if (sysctl_netrom_reset_circuit && |
| 916 | /* | 920 | (frametype != NR_RESET || flags != 0)) |
| 917 | * Never reply to a CONNACK/CHOKE. | 921 | nr_transmit_reset(skb, 1); |
| 918 | */ | 922 | |
| 919 | if (frametype != NR_CONNACK || flags != NR_CHOKE_FLAG) | ||
| 920 | nr_transmit_refusal(skb, 1); | ||
| 921 | #endif | ||
| 922 | return 0; | 923 | return 0; |
| 923 | } | 924 | } |
| 924 | 925 | ||
| @@ -1187,9 +1188,7 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
| 1187 | } | 1188 | } |
| 1188 | 1189 | ||
| 1189 | case SIOCGSTAMP: | 1190 | case SIOCGSTAMP: |
| 1190 | ret = -EINVAL; | 1191 | ret = sock_get_timestamp(sk, argp); |
| 1191 | if (sk != NULL) | ||
| 1192 | ret = sock_get_timestamp(sk, argp); | ||
| 1193 | release_sock(sk); | 1192 | release_sock(sk); |
| 1194 | return ret; | 1193 | return ret; |
| 1195 | 1194 | ||
| @@ -1393,8 +1392,7 @@ static int __init nr_proto_init(void) | |||
| 1393 | struct net_device *dev; | 1392 | struct net_device *dev; |
| 1394 | 1393 | ||
| 1395 | sprintf(name, "nr%d", i); | 1394 | sprintf(name, "nr%d", i); |
| 1396 | dev = alloc_netdev(sizeof(struct net_device_stats), name, | 1395 | dev = alloc_netdev(sizeof(struct nr_private), name, nr_setup); |
| 1397 | nr_setup); | ||
| 1398 | if (!dev) { | 1396 | if (!dev) { |
| 1399 | printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device structure\n"); | 1397 | printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device structure\n"); |
| 1400 | goto fail; | 1398 | goto fail; |
diff --git a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c index 263da4c26494..4e66eef9a034 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) | |||
| 47 | struct net_device_stats *stats = netdev_priv(dev); | 47 | struct net_device_stats *stats = netdev_priv(dev); |
| 48 | 48 | ||
| 49 | if (!netif_running(dev)) { | 49 | if (!netif_running(dev)) { |
| 50 | stats->rx_errors++; | 50 | stats->rx_dropped++; |
| 51 | return 0; | 51 | return 0; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| @@ -71,15 +71,10 @@ int nr_rx_ip(struct sk_buff *skb, struct net_device *dev) | |||
| 71 | 71 | ||
| 72 | static int nr_rebuild_header(struct sk_buff *skb) | 72 | static int nr_rebuild_header(struct sk_buff *skb) |
| 73 | { | 73 | { |
| 74 | struct net_device *dev = skb->dev; | ||
| 75 | struct net_device_stats *stats = netdev_priv(dev); | ||
| 76 | struct sk_buff *skbn; | ||
| 77 | unsigned char *bp = skb->data; | 74 | unsigned char *bp = skb->data; |
| 78 | int len; | ||
| 79 | 75 | ||
| 80 | if (arp_find(bp + 7, skb)) { | 76 | if (arp_find(bp + 7, skb)) |
| 81 | return 1; | 77 | return 1; |
| 82 | } | ||
| 83 | 78 | ||
| 84 | bp[6] &= ~AX25_CBIT; | 79 | bp[6] &= ~AX25_CBIT; |
| 85 | bp[6] &= ~AX25_EBIT; | 80 | bp[6] &= ~AX25_EBIT; |
| @@ -90,27 +85,7 @@ static int nr_rebuild_header(struct sk_buff *skb) | |||
| 90 | bp[6] |= AX25_EBIT; | 85 | bp[6] |= AX25_EBIT; |
| 91 | bp[6] |= AX25_SSSID_SPARE; | 86 | bp[6] |= AX25_SSSID_SPARE; |
| 92 | 87 | ||
| 93 | if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL) { | 88 | return 0; |
| 94 | kfree_skb(skb); | ||
| 95 | return 1; | ||
| 96 | } | ||
| 97 | |||
| 98 | if (skb->sk != NULL) | ||
| 99 | skb_set_owner_w(skbn, skb->sk); | ||
| 100 | |||
| 101 | kfree_skb(skb); | ||
| 102 | |||
| 103 | len = skbn->len; | ||
| 104 | |||
| 105 | if (!nr_route_frame(skbn, NULL)) { | ||
| 106 | kfree_skb(skbn); | ||
| 107 | stats->tx_errors++; | ||
| 108 | } | ||
| 109 | |||
| 110 | stats->tx_packets++; | ||
| 111 | stats->tx_bytes += len; | ||
| 112 | |||
| 113 | return 1; | ||
| 114 | } | 89 | } |
| 115 | 90 | ||
| 116 | #else | 91 | #else |
| @@ -185,15 +160,27 @@ static int nr_close(struct net_device *dev) | |||
| 185 | 160 | ||
| 186 | static int nr_xmit(struct sk_buff *skb, struct net_device *dev) | 161 | static int nr_xmit(struct sk_buff *skb, struct net_device *dev) |
| 187 | { | 162 | { |
| 188 | struct net_device_stats *stats = netdev_priv(dev); | 163 | struct nr_private *nr = netdev_priv(dev); |
| 189 | dev_kfree_skb(skb); | 164 | struct net_device_stats *stats = &nr->stats; |
| 190 | stats->tx_errors++; | 165 | unsigned int len = skb->len; |
| 166 | |||
| 167 | if (!nr_route_frame(skb, NULL)) { | ||
| 168 | kfree_skb(skb); | ||
| 169 | stats->tx_errors++; | ||
| 170 | return 0; | ||
| 171 | } | ||
| 172 | |||
| 173 | stats->tx_packets++; | ||
| 174 | stats->tx_bytes += len; | ||
| 175 | |||
| 191 | return 0; | 176 | return 0; |
| 192 | } | 177 | } |
| 193 | 178 | ||
| 194 | static struct net_device_stats *nr_get_stats(struct net_device *dev) | 179 | static struct net_device_stats *nr_get_stats(struct net_device *dev) |
| 195 | { | 180 | { |
| 196 | return netdev_priv(dev); | 181 | struct nr_private *nr = netdev_priv(dev); |
| 182 | |||
| 183 | return &nr->stats; | ||
| 197 | } | 184 | } |
| 198 | 185 | ||
| 199 | void nr_setup(struct net_device *dev) | 186 | void nr_setup(struct net_device *dev) |
| @@ -208,12 +195,11 @@ void nr_setup(struct net_device *dev) | |||
| 208 | dev->hard_header_len = NR_NETWORK_LEN + NR_TRANSPORT_LEN; | 195 | dev->hard_header_len = NR_NETWORK_LEN + NR_TRANSPORT_LEN; |
| 209 | dev->addr_len = AX25_ADDR_LEN; | 196 | dev->addr_len = AX25_ADDR_LEN; |
| 210 | dev->type = ARPHRD_NETROM; | 197 | dev->type = ARPHRD_NETROM; |
| 211 | dev->tx_queue_len = 40; | ||
| 212 | dev->rebuild_header = nr_rebuild_header; | 198 | dev->rebuild_header = nr_rebuild_header; |
| 213 | dev->set_mac_address = nr_set_mac_address; | 199 | dev->set_mac_address = nr_set_mac_address; |
| 214 | 200 | ||
| 215 | /* New-style flags. */ | 201 | /* New-style flags. */ |
| 216 | dev->flags = 0; | 202 | dev->flags = IFF_NOARP; |
| 217 | 203 | ||
| 218 | dev->get_stats = nr_get_stats; | 204 | dev->get_stats = nr_get_stats; |
| 219 | } | 205 | } |
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, | |||
| 98 | nr_disconnect(sk, ECONNREFUSED); | 98 | nr_disconnect(sk, ECONNREFUSED); |
| 99 | break; | 99 | break; |
| 100 | 100 | ||
| 101 | case NR_RESET: | ||
| 102 | if (sysctl_netrom_reset_circuit); | ||
| 103 | nr_disconnect(sk, ECONNRESET); | ||
| 104 | break; | ||
| 105 | |||
| 101 | default: | 106 | default: |
| 102 | break; | 107 | break; |
| 103 | } | 108 | } |
| @@ -124,6 +129,11 @@ static int nr_state2_machine(struct sock *sk, struct sk_buff *skb, | |||
| 124 | nr_disconnect(sk, 0); | 129 | nr_disconnect(sk, 0); |
| 125 | break; | 130 | break; |
| 126 | 131 | ||
| 132 | case NR_RESET: | ||
| 133 | if (sysctl_netrom_reset_circuit); | ||
| 134 | nr_disconnect(sk, ECONNRESET); | ||
| 135 | break; | ||
| 136 | |||
| 127 | default: | 137 | default: |
| 128 | break; | 138 | break; |
| 129 | } | 139 | } |
| @@ -254,6 +264,11 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype | |||
| 254 | } | 264 | } |
| 255 | break; | 265 | break; |
| 256 | 266 | ||
| 267 | case NR_RESET: | ||
| 268 | if (sysctl_netrom_reset_circuit); | ||
| 269 | nr_disconnect(sk, ECONNRESET); | ||
| 270 | break; | ||
| 271 | |||
| 257 | default: | 272 | default: |
| 258 | break; | 273 | break; |
| 259 | } | 274 | } |
diff --git a/net/netrom/nr_loopback.c b/net/netrom/nr_loopback.c index 165b2abce110..e856ae1b360a 100644 --- a/net/netrom/nr_loopback.c +++ b/net/netrom/nr_loopback.c | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | static void nr_loopback_timer(unsigned long); | 17 | static void nr_loopback_timer(unsigned long); |
| 18 | 18 | ||
| 19 | static struct sk_buff_head loopback_queue; | 19 | static struct sk_buff_head loopback_queue; |
| 20 | static struct timer_list loopback_timer = TIMER_INITIALIZER(nr_loopback_timer, 0, 0); | 20 | static DEFINE_TIMER(loopback_timer, nr_loopback_timer, 0, 0); |
| 21 | 21 | ||
| 22 | void __init nr_loopback_init(void) | 22 | void __init nr_loopback_init(void) |
| 23 | { | 23 | { |
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) | |||
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | /* | 212 | /* |
| 213 | * This routine is called when a Connect Acknowledge with the Choke Flag | 213 | * This routine is called to send an error reply. |
| 214 | * set is needed to refuse a connection. | ||
| 215 | */ | 214 | */ |
| 216 | void nr_transmit_refusal(struct sk_buff *skb, int mine) | 215 | void __nr_transmit_reply(struct sk_buff *skb, int mine, unsigned char cmdflags) |
| 217 | { | 216 | { |
| 218 | struct sk_buff *skbn; | 217 | struct sk_buff *skbn; |
| 219 | unsigned char *dptr; | 218 | unsigned char *dptr; |
| @@ -254,7 +253,7 @@ void nr_transmit_refusal(struct sk_buff *skb, int mine) | |||
| 254 | *dptr++ = 0; | 253 | *dptr++ = 0; |
| 255 | } | 254 | } |
| 256 | 255 | ||
| 257 | *dptr++ = NR_CONNACK | NR_CHOKE_FLAG; | 256 | *dptr++ = cmdflags; |
| 258 | *dptr++ = 0; | 257 | *dptr++ = 0; |
| 259 | 258 | ||
| 260 | if (!nr_route_frame(skbn, NULL)) | 259 | 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}; | |||
| 30 | static int max_idle[] = {65535 * HZ}; | 30 | static int max_idle[] = {65535 * HZ}; |
| 31 | static int min_route[] = {0}, max_route[] = {1}; | 31 | static int min_route[] = {0}, max_route[] = {1}; |
| 32 | static int min_fails[] = {1}, max_fails[] = {10}; | 32 | static int min_fails[] = {1}, max_fails[] = {10}; |
| 33 | static int min_reset[] = {0}, max_reset[] = {1}; | ||
| 33 | 34 | ||
| 34 | static struct ctl_table_header *nr_table_header; | 35 | static struct ctl_table_header *nr_table_header; |
| 35 | 36 | ||
| @@ -155,6 +156,17 @@ static ctl_table nr_table[] = { | |||
| 155 | .extra1 = &min_fails, | 156 | .extra1 = &min_fails, |
| 156 | .extra2 = &max_fails | 157 | .extra2 = &max_fails |
| 157 | }, | 158 | }, |
| 159 | { | ||
| 160 | .ctl_name = NET_NETROM_RESET, | ||
| 161 | .procname = "reset", | ||
| 162 | .data = &sysctl_netrom_reset_circuit, | ||
| 163 | .maxlen = sizeof(int), | ||
| 164 | .mode = 0644, | ||
| 165 | .proc_handler = &proc_dointvec_minmax, | ||
| 166 | .strategy = &sysctl_intvec, | ||
| 167 | .extra1 = &min_reset, | ||
| 168 | .extra2 = &max_reset | ||
| 169 | }, | ||
| 158 | { .ctl_name = 0 } | 170 | { .ctl_name = 0 } |
| 159 | }; | 171 | }; |
| 160 | 172 | ||
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 3077878ed4f0..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) | |||
| 1243 | amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc); | 1243 | amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc); |
| 1244 | if (amount < 0) | 1244 | if (amount < 0) |
| 1245 | amount = 0; | 1245 | amount = 0; |
| 1246 | return put_user(amount, (unsigned int __user *)argp); | 1246 | return put_user(amount, (unsigned int __user *) argp); |
| 1247 | } | 1247 | } |
| 1248 | 1248 | ||
| 1249 | case TIOCINQ: { | 1249 | case TIOCINQ: { |
| @@ -1252,13 +1252,11 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
| 1252 | /* These two are safe on a single CPU system as only user tasks fiddle here */ | 1252 | /* These two are safe on a single CPU system as only user tasks fiddle here */ |
| 1253 | if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) | 1253 | if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) |
| 1254 | amount = skb->len; | 1254 | amount = skb->len; |
| 1255 | return put_user(amount, (unsigned int __user *)argp); | 1255 | return put_user(amount, (unsigned int __user *) argp); |
| 1256 | } | 1256 | } |
| 1257 | 1257 | ||
| 1258 | case SIOCGSTAMP: | 1258 | case SIOCGSTAMP: |
| 1259 | if (sk != NULL) | 1259 | return sock_get_timestamp(sk, (struct timeval __user *) argp); |
| 1260 | return sock_get_timestamp(sk, (struct timeval __user *)argp); | ||
| 1261 | return -EINVAL; | ||
| 1262 | 1260 | ||
| 1263 | case SIOCGIFADDR: | 1261 | case SIOCGIFADDR: |
| 1264 | case SIOCSIFADDR: | 1262 | case SIOCSIFADDR: |
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) | |||
| 149 | dev->set_mac_address = rose_set_mac_address; | 149 | dev->set_mac_address = rose_set_mac_address; |
| 150 | 150 | ||
| 151 | /* New-style flags. */ | 151 | /* New-style flags. */ |
| 152 | dev->flags = 0; | 152 | dev->flags = IFF_NOARP; |
| 153 | dev->get_stats = rose_get_stats; | 153 | dev->get_stats = rose_get_stats; |
| 154 | } | 154 | } |
diff --git a/net/rose/rose_subr.c b/net/rose/rose_subr.c index 02891ce2db37..36a77944622b 100644 --- a/net/rose/rose_subr.c +++ b/net/rose/rose_subr.c | |||
| @@ -337,13 +337,13 @@ static int rose_parse_ccitt(unsigned char *p, struct rose_facilities_struct *fac | |||
| 337 | memcpy(&facilities->source_addr, p + 7, ROSE_ADDR_LEN); | 337 | memcpy(&facilities->source_addr, p + 7, ROSE_ADDR_LEN); |
| 338 | memcpy(callsign, p + 12, l - 10); | 338 | memcpy(callsign, p + 12, l - 10); |
| 339 | callsign[l - 10] = '\0'; | 339 | callsign[l - 10] = '\0'; |
| 340 | facilities->source_call = *asc2ax(callsign); | 340 | asc2ax(&facilities->source_call, callsign); |
| 341 | } | 341 | } |
| 342 | if (*p == FAC_CCITT_SRC_NSAP) { | 342 | if (*p == FAC_CCITT_SRC_NSAP) { |
| 343 | memcpy(&facilities->dest_addr, p + 7, ROSE_ADDR_LEN); | 343 | memcpy(&facilities->dest_addr, p + 7, ROSE_ADDR_LEN); |
| 344 | memcpy(callsign, p + 12, l - 10); | 344 | memcpy(callsign, p + 12, l - 10); |
| 345 | callsign[l - 10] = '\0'; | 345 | callsign[l - 10] = '\0'; |
| 346 | facilities->dest_call = *asc2ax(callsign); | 346 | asc2ax(&facilities->dest_call, callsign); |
| 347 | } | 347 | } |
| 348 | p += l + 2; | 348 | p += l + 2; |
| 349 | n += l + 2; | 349 | n += l + 2; |
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 737681cb9a92..31570b9a6e9a 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c | |||
| @@ -1194,7 +1194,7 @@ EXPORT_SYMBOL(psched_time_base); | |||
| 1194 | * with 32-bit get_cycles(). Safe up to 4GHz CPU. | 1194 | * with 32-bit get_cycles(). Safe up to 4GHz CPU. |
| 1195 | */ | 1195 | */ |
| 1196 | static void psched_tick(unsigned long); | 1196 | static void psched_tick(unsigned long); |
| 1197 | static struct timer_list psched_timer = TIMER_INITIALIZER(psched_tick, 0, 0); | 1197 | static DEFINE_TIMER(psched_timer, psched_tick, 0, 0); |
| 1198 | 1198 | ||
| 1199 | static void psched_tick(unsigned long dummy) | 1199 | static void psched_tick(unsigned long dummy) |
| 1200 | { | 1200 | { |
diff --git a/net/socket.c b/net/socket.c index e1bd5d84d7bf..c699e93c33d7 100644 --- a/net/socket.c +++ b/net/socket.c | |||
| @@ -1745,10 +1745,11 @@ asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags) | |||
| 1745 | goto out_freeiov; | 1745 | goto out_freeiov; |
| 1746 | ctl_len = msg_sys.msg_controllen; | 1746 | ctl_len = msg_sys.msg_controllen; |
| 1747 | if ((MSG_CMSG_COMPAT & flags) && ctl_len) { | 1747 | if ((MSG_CMSG_COMPAT & flags) && ctl_len) { |
| 1748 | err = cmsghdr_from_user_compat_to_kern(&msg_sys, ctl, sizeof(ctl)); | 1748 | err = cmsghdr_from_user_compat_to_kern(&msg_sys, sock->sk, ctl, sizeof(ctl)); |
| 1749 | if (err) | 1749 | if (err) |
| 1750 | goto out_freeiov; | 1750 | goto out_freeiov; |
| 1751 | ctl_buf = msg_sys.msg_control; | 1751 | ctl_buf = msg_sys.msg_control; |
| 1752 | ctl_len = msg_sys.msg_controllen; | ||
| 1752 | } else if (ctl_len) { | 1753 | } else if (ctl_len) { |
| 1753 | if (ctl_len > sizeof(ctl)) | 1754 | if (ctl_len > sizeof(ctl)) |
| 1754 | { | 1755 | { |
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) | |||
| 1170 | while (rqstp->rq_arghi < pages) { | 1170 | while (rqstp->rq_arghi < pages) { |
| 1171 | struct page *p = alloc_page(GFP_KERNEL); | 1171 | struct page *p = alloc_page(GFP_KERNEL); |
| 1172 | if (!p) { | 1172 | if (!p) { |
| 1173 | set_current_state(TASK_UNINTERRUPTIBLE); | 1173 | schedule_timeout_uninterruptible(msecs_to_jiffies(500)); |
| 1174 | schedule_timeout(HZ/2); | ||
| 1175 | continue; | 1174 | continue; |
| 1176 | } | 1175 | } |
| 1177 | rqstp->rq_argpages[rqstp->rq_arghi++] = p; | 1176 | rqstp->rq_argpages[rqstp->rq_arghi++] = p; |
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 83c8135e1764..fda737d77edc 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
| @@ -765,8 +765,8 @@ restart: | |||
| 765 | switch (policy->action) { | 765 | switch (policy->action) { |
| 766 | case XFRM_POLICY_BLOCK: | 766 | case XFRM_POLICY_BLOCK: |
| 767 | /* Prohibit the flow */ | 767 | /* Prohibit the flow */ |
| 768 | xfrm_pol_put(policy); | 768 | err = -EPERM; |
| 769 | return -EPERM; | 769 | goto error; |
| 770 | 770 | ||
| 771 | case XFRM_POLICY_ALLOW: | 771 | case XFRM_POLICY_ALLOW: |
| 772 | if (policy->xfrm_nr == 0) { | 772 | if (policy->xfrm_nr == 0) { |
| @@ -782,8 +782,8 @@ restart: | |||
| 782 | */ | 782 | */ |
| 783 | dst = xfrm_find_bundle(fl, policy, family); | 783 | dst = xfrm_find_bundle(fl, policy, family); |
| 784 | if (IS_ERR(dst)) { | 784 | if (IS_ERR(dst)) { |
| 785 | xfrm_pol_put(policy); | 785 | err = PTR_ERR(dst); |
| 786 | return PTR_ERR(dst); | 786 | goto error; |
| 787 | } | 787 | } |
| 788 | 788 | ||
| 789 | if (dst) | 789 | if (dst) |
