diff options
Diffstat (limited to 'net')
155 files changed, 1540 insertions, 1002 deletions
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index b7889782047e..c1b92cab46c7 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c | |||
| @@ -163,7 +163,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, | |||
| 163 | goto err_unlock; | 163 | goto err_unlock; |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | rx_stats = per_cpu_ptr(vlan_dev_info(dev)->vlan_rx_stats, | 166 | rx_stats = per_cpu_ptr(vlan_dev_info(skb->dev)->vlan_rx_stats, |
| 167 | smp_processor_id()); | 167 | smp_processor_id()); |
| 168 | rx_stats->rx_packets++; | 168 | rx_stats->rx_packets++; |
| 169 | rx_stats->rx_bytes += skb->len; | 169 | rx_stats->rx_bytes += skb->len; |
diff --git a/net/9p/client.c b/net/9p/client.c index 8af95b2dddd6..09d4f1e2e4a8 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
| @@ -69,7 +69,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...); | |||
| 69 | 69 | ||
| 70 | static int parse_opts(char *opts, struct p9_client *clnt) | 70 | static int parse_opts(char *opts, struct p9_client *clnt) |
| 71 | { | 71 | { |
| 72 | char *options; | 72 | char *options, *tmp_options; |
| 73 | char *p; | 73 | char *p; |
| 74 | substring_t args[MAX_OPT_ARGS]; | 74 | substring_t args[MAX_OPT_ARGS]; |
| 75 | int option; | 75 | int option; |
| @@ -81,12 +81,13 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
| 81 | if (!opts) | 81 | if (!opts) |
| 82 | return 0; | 82 | return 0; |
| 83 | 83 | ||
| 84 | options = kstrdup(opts, GFP_KERNEL); | 84 | tmp_options = kstrdup(opts, GFP_KERNEL); |
| 85 | if (!options) { | 85 | if (!tmp_options) { |
| 86 | P9_DPRINTK(P9_DEBUG_ERROR, | 86 | P9_DPRINTK(P9_DEBUG_ERROR, |
| 87 | "failed to allocate copy of option string\n"); | 87 | "failed to allocate copy of option string\n"); |
| 88 | return -ENOMEM; | 88 | return -ENOMEM; |
| 89 | } | 89 | } |
| 90 | options = tmp_options; | ||
| 90 | 91 | ||
| 91 | while ((p = strsep(&options, ",")) != NULL) { | 92 | while ((p = strsep(&options, ",")) != NULL) { |
| 92 | int token; | 93 | int token; |
| @@ -108,6 +109,13 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
| 108 | break; | 109 | break; |
| 109 | case Opt_trans: | 110 | case Opt_trans: |
| 110 | clnt->trans_mod = v9fs_get_trans_by_name(&args[0]); | 111 | clnt->trans_mod = v9fs_get_trans_by_name(&args[0]); |
| 112 | if(clnt->trans_mod == NULL) { | ||
| 113 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
| 114 | "Could not find request transport: %s\n", | ||
| 115 | (char *) &args[0]); | ||
| 116 | ret = -EINVAL; | ||
| 117 | goto free_and_return; | ||
| 118 | } | ||
| 111 | break; | 119 | break; |
| 112 | case Opt_legacy: | 120 | case Opt_legacy: |
| 113 | clnt->dotu = 0; | 121 | clnt->dotu = 0; |
| @@ -117,7 +125,8 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
| 117 | } | 125 | } |
| 118 | } | 126 | } |
| 119 | 127 | ||
| 120 | kfree(options); | 128 | free_and_return: |
| 129 | kfree(tmp_options); | ||
| 121 | return ret; | 130 | return ret; |
| 122 | } | 131 | } |
| 123 | 132 | ||
| @@ -667,18 +676,12 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) | |||
| 667 | clnt->trans = NULL; | 676 | clnt->trans = NULL; |
| 668 | spin_lock_init(&clnt->lock); | 677 | spin_lock_init(&clnt->lock); |
| 669 | INIT_LIST_HEAD(&clnt->fidlist); | 678 | INIT_LIST_HEAD(&clnt->fidlist); |
| 670 | clnt->fidpool = p9_idpool_create(); | ||
| 671 | if (IS_ERR(clnt->fidpool)) { | ||
| 672 | err = PTR_ERR(clnt->fidpool); | ||
| 673 | clnt->fidpool = NULL; | ||
| 674 | goto error; | ||
| 675 | } | ||
| 676 | 679 | ||
| 677 | p9_tag_init(clnt); | 680 | p9_tag_init(clnt); |
| 678 | 681 | ||
| 679 | err = parse_opts(options, clnt); | 682 | err = parse_opts(options, clnt); |
| 680 | if (err < 0) | 683 | if (err < 0) |
| 681 | goto error; | 684 | goto free_client; |
| 682 | 685 | ||
| 683 | if (!clnt->trans_mod) | 686 | if (!clnt->trans_mod) |
| 684 | clnt->trans_mod = v9fs_get_default_trans(); | 687 | clnt->trans_mod = v9fs_get_default_trans(); |
| @@ -687,7 +690,14 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) | |||
| 687 | err = -EPROTONOSUPPORT; | 690 | err = -EPROTONOSUPPORT; |
| 688 | P9_DPRINTK(P9_DEBUG_ERROR, | 691 | P9_DPRINTK(P9_DEBUG_ERROR, |
| 689 | "No transport defined or default transport\n"); | 692 | "No transport defined or default transport\n"); |
| 690 | goto error; | 693 | goto free_client; |
| 694 | } | ||
| 695 | |||
| 696 | clnt->fidpool = p9_idpool_create(); | ||
| 697 | if (IS_ERR(clnt->fidpool)) { | ||
| 698 | err = PTR_ERR(clnt->fidpool); | ||
| 699 | clnt->fidpool = NULL; | ||
| 700 | goto put_trans; | ||
| 691 | } | 701 | } |
| 692 | 702 | ||
| 693 | P9_DPRINTK(P9_DEBUG_MUX, "clnt %p trans %p msize %d dotu %d\n", | 703 | P9_DPRINTK(P9_DEBUG_MUX, "clnt %p trans %p msize %d dotu %d\n", |
| @@ -695,19 +705,25 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) | |||
| 695 | 705 | ||
| 696 | err = clnt->trans_mod->create(clnt, dev_name, options); | 706 | err = clnt->trans_mod->create(clnt, dev_name, options); |
| 697 | if (err) | 707 | if (err) |
| 698 | goto error; | 708 | goto destroy_fidpool; |
| 699 | 709 | ||
| 700 | if ((clnt->msize+P9_IOHDRSZ) > clnt->trans_mod->maxsize) | 710 | if ((clnt->msize+P9_IOHDRSZ) > clnt->trans_mod->maxsize) |
| 701 | clnt->msize = clnt->trans_mod->maxsize-P9_IOHDRSZ; | 711 | clnt->msize = clnt->trans_mod->maxsize-P9_IOHDRSZ; |
| 702 | 712 | ||
| 703 | err = p9_client_version(clnt); | 713 | err = p9_client_version(clnt); |
| 704 | if (err) | 714 | if (err) |
| 705 | goto error; | 715 | goto close_trans; |
| 706 | 716 | ||
| 707 | return clnt; | 717 | return clnt; |
| 708 | 718 | ||
| 709 | error: | 719 | close_trans: |
| 710 | p9_client_destroy(clnt); | 720 | clnt->trans_mod->close(clnt); |
| 721 | destroy_fidpool: | ||
| 722 | p9_idpool_destroy(clnt->fidpool); | ||
| 723 | put_trans: | ||
| 724 | v9fs_put_trans(clnt->trans_mod); | ||
| 725 | free_client: | ||
| 726 | kfree(clnt); | ||
| 711 | return ERR_PTR(err); | 727 | return ERR_PTR(err); |
| 712 | } | 728 | } |
| 713 | EXPORT_SYMBOL(p9_client_create); | 729 | EXPORT_SYMBOL(p9_client_create); |
| @@ -1214,10 +1230,11 @@ static int p9_client_statsize(struct p9_wstat *wst, int optional) | |||
| 1214 | { | 1230 | { |
| 1215 | int ret; | 1231 | int ret; |
| 1216 | 1232 | ||
| 1233 | /* NOTE: size shouldn't include its own length */ | ||
| 1217 | /* size[2] type[2] dev[4] qid[13] */ | 1234 | /* size[2] type[2] dev[4] qid[13] */ |
| 1218 | /* mode[4] atime[4] mtime[4] length[8]*/ | 1235 | /* mode[4] atime[4] mtime[4] length[8]*/ |
| 1219 | /* name[s] uid[s] gid[s] muid[s] */ | 1236 | /* name[s] uid[s] gid[s] muid[s] */ |
| 1220 | ret = 2+2+4+13+4+4+4+8+2+2+2+2; | 1237 | ret = 2+4+13+4+4+4+8+2+2+2+2; |
| 1221 | 1238 | ||
| 1222 | if (wst->name) | 1239 | if (wst->name) |
| 1223 | ret += strlen(wst->name); | 1240 | ret += strlen(wst->name); |
| @@ -1258,7 +1275,7 @@ int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst) | |||
| 1258 | wst->name, wst->uid, wst->gid, wst->muid, wst->extension, | 1275 | wst->name, wst->uid, wst->gid, wst->muid, wst->extension, |
| 1259 | wst->n_uid, wst->n_gid, wst->n_muid); | 1276 | wst->n_uid, wst->n_gid, wst->n_muid); |
| 1260 | 1277 | ||
| 1261 | req = p9_client_rpc(clnt, P9_TWSTAT, "dwS", fid->fid, wst->size, wst); | 1278 | req = p9_client_rpc(clnt, P9_TWSTAT, "dwS", fid->fid, wst->size+2, wst); |
| 1262 | if (IS_ERR(req)) { | 1279 | if (IS_ERR(req)) { |
| 1263 | err = PTR_ERR(req); | 1280 | err = PTR_ERR(req); |
| 1264 | goto error; | 1281 | goto error; |
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index 4dd873e3a1bb..31d0b05582a9 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c | |||
| @@ -42,6 +42,8 @@ | |||
| 42 | #include <net/9p/client.h> | 42 | #include <net/9p/client.h> |
| 43 | #include <net/9p/transport.h> | 43 | #include <net/9p/transport.h> |
| 44 | 44 | ||
| 45 | #include <linux/syscalls.h> /* killme */ | ||
| 46 | |||
| 45 | #define P9_PORT 564 | 47 | #define P9_PORT 564 |
| 46 | #define MAX_SOCK_BUF (64*1024) | 48 | #define MAX_SOCK_BUF (64*1024) |
| 47 | #define MAXPOLLWADDR 2 | 49 | #define MAXPOLLWADDR 2 |
| @@ -712,7 +714,7 @@ static int parse_opts(char *params, struct p9_fd_opts *opts) | |||
| 712 | char *p; | 714 | char *p; |
| 713 | substring_t args[MAX_OPT_ARGS]; | 715 | substring_t args[MAX_OPT_ARGS]; |
| 714 | int option; | 716 | int option; |
| 715 | char *options; | 717 | char *options, *tmp_options; |
| 716 | int ret; | 718 | int ret; |
| 717 | 719 | ||
| 718 | opts->port = P9_PORT; | 720 | opts->port = P9_PORT; |
| @@ -722,12 +724,13 @@ static int parse_opts(char *params, struct p9_fd_opts *opts) | |||
| 722 | if (!params) | 724 | if (!params) |
| 723 | return 0; | 725 | return 0; |
| 724 | 726 | ||
| 725 | options = kstrdup(params, GFP_KERNEL); | 727 | tmp_options = kstrdup(params, GFP_KERNEL); |
| 726 | if (!options) { | 728 | if (!tmp_options) { |
| 727 | P9_DPRINTK(P9_DEBUG_ERROR, | 729 | P9_DPRINTK(P9_DEBUG_ERROR, |
| 728 | "failed to allocate copy of option string\n"); | 730 | "failed to allocate copy of option string\n"); |
| 729 | return -ENOMEM; | 731 | return -ENOMEM; |
| 730 | } | 732 | } |
| 733 | options = tmp_options; | ||
| 731 | 734 | ||
| 732 | while ((p = strsep(&options, ",")) != NULL) { | 735 | while ((p = strsep(&options, ",")) != NULL) { |
| 733 | int token; | 736 | int token; |
| @@ -758,7 +761,8 @@ static int parse_opts(char *params, struct p9_fd_opts *opts) | |||
| 758 | continue; | 761 | continue; |
| 759 | } | 762 | } |
| 760 | } | 763 | } |
| 761 | kfree(options); | 764 | |
| 765 | kfree(tmp_options); | ||
| 762 | return 0; | 766 | return 0; |
| 763 | } | 767 | } |
| 764 | 768 | ||
| @@ -788,24 +792,41 @@ static int p9_fd_open(struct p9_client *client, int rfd, int wfd) | |||
| 788 | 792 | ||
| 789 | static int p9_socket_open(struct p9_client *client, struct socket *csocket) | 793 | static int p9_socket_open(struct p9_client *client, struct socket *csocket) |
| 790 | { | 794 | { |
| 791 | int fd, ret; | 795 | struct p9_trans_fd *p; |
| 796 | int ret, fd; | ||
| 797 | |||
| 798 | p = kmalloc(sizeof(struct p9_trans_fd), GFP_KERNEL); | ||
| 799 | if (!p) | ||
| 800 | return -ENOMEM; | ||
| 792 | 801 | ||
| 793 | csocket->sk->sk_allocation = GFP_NOIO; | 802 | csocket->sk->sk_allocation = GFP_NOIO; |
| 794 | fd = sock_map_fd(csocket, 0); | 803 | fd = sock_map_fd(csocket, 0); |
| 795 | if (fd < 0) { | 804 | if (fd < 0) { |
| 796 | P9_EPRINTK(KERN_ERR, "p9_socket_open: failed to map fd\n"); | 805 | P9_EPRINTK(KERN_ERR, "p9_socket_open: failed to map fd\n"); |
| 806 | sock_release(csocket); | ||
| 807 | kfree(p); | ||
| 797 | return fd; | 808 | return fd; |
| 798 | } | 809 | } |
| 799 | 810 | ||
| 800 | ret = p9_fd_open(client, fd, fd); | 811 | get_file(csocket->file); |
| 801 | if (ret < 0) { | 812 | get_file(csocket->file); |
| 802 | P9_EPRINTK(KERN_ERR, "p9_socket_open: failed to open fd\n"); | 813 | p->wr = p->rd = csocket->file; |
| 814 | client->trans = p; | ||
| 815 | client->status = Connected; | ||
| 816 | |||
| 817 | sys_close(fd); /* still racy */ | ||
| 818 | |||
| 819 | p->rd->f_flags |= O_NONBLOCK; | ||
| 820 | |||
| 821 | p->conn = p9_conn_create(client); | ||
| 822 | if (IS_ERR(p->conn)) { | ||
| 823 | ret = PTR_ERR(p->conn); | ||
| 824 | p->conn = NULL; | ||
| 825 | kfree(p); | ||
| 826 | sockfd_put(csocket); | ||
| 803 | sockfd_put(csocket); | 827 | sockfd_put(csocket); |
| 804 | return ret; | 828 | return ret; |
| 805 | } | 829 | } |
| 806 | |||
| 807 | ((struct p9_trans_fd *)client->trans)->rd->f_flags |= O_NONBLOCK; | ||
| 808 | |||
| 809 | return 0; | 830 | return 0; |
| 810 | } | 831 | } |
| 811 | 832 | ||
| @@ -883,7 +904,6 @@ p9_fd_create_tcp(struct p9_client *client, const char *addr, char *args) | |||
| 883 | struct socket *csocket; | 904 | struct socket *csocket; |
| 884 | struct sockaddr_in sin_server; | 905 | struct sockaddr_in sin_server; |
| 885 | struct p9_fd_opts opts; | 906 | struct p9_fd_opts opts; |
| 886 | struct p9_trans_fd *p = NULL; /* this gets allocated in p9_fd_open */ | ||
| 887 | 907 | ||
| 888 | err = parse_opts(args, &opts); | 908 | err = parse_opts(args, &opts); |
| 889 | if (err < 0) | 909 | if (err < 0) |
| @@ -897,12 +917,11 @@ p9_fd_create_tcp(struct p9_client *client, const char *addr, char *args) | |||
| 897 | sin_server.sin_family = AF_INET; | 917 | sin_server.sin_family = AF_INET; |
| 898 | sin_server.sin_addr.s_addr = in_aton(addr); | 918 | sin_server.sin_addr.s_addr = in_aton(addr); |
| 899 | sin_server.sin_port = htons(opts.port); | 919 | sin_server.sin_port = htons(opts.port); |
| 900 | sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &csocket); | 920 | err = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &csocket); |
| 901 | 921 | ||
| 902 | if (!csocket) { | 922 | if (err) { |
| 903 | P9_EPRINTK(KERN_ERR, "p9_trans_tcp: problem creating socket\n"); | 923 | P9_EPRINTK(KERN_ERR, "p9_trans_tcp: problem creating socket\n"); |
| 904 | err = -EIO; | 924 | return err; |
| 905 | goto error; | ||
| 906 | } | 925 | } |
| 907 | 926 | ||
| 908 | err = csocket->ops->connect(csocket, | 927 | err = csocket->ops->connect(csocket, |
| @@ -912,30 +931,11 @@ p9_fd_create_tcp(struct p9_client *client, const char *addr, char *args) | |||
| 912 | P9_EPRINTK(KERN_ERR, | 931 | P9_EPRINTK(KERN_ERR, |
| 913 | "p9_trans_tcp: problem connecting socket to %s\n", | 932 | "p9_trans_tcp: problem connecting socket to %s\n", |
| 914 | addr); | 933 | addr); |
| 915 | goto error; | ||
| 916 | } | ||
| 917 | |||
| 918 | err = p9_socket_open(client, csocket); | ||
| 919 | if (err < 0) | ||
| 920 | goto error; | ||
| 921 | |||
| 922 | p = (struct p9_trans_fd *) client->trans; | ||
| 923 | p->conn = p9_conn_create(client); | ||
| 924 | if (IS_ERR(p->conn)) { | ||
| 925 | err = PTR_ERR(p->conn); | ||
| 926 | p->conn = NULL; | ||
| 927 | goto error; | ||
| 928 | } | ||
| 929 | |||
| 930 | return 0; | ||
| 931 | |||
| 932 | error: | ||
| 933 | if (csocket) | ||
| 934 | sock_release(csocket); | 934 | sock_release(csocket); |
| 935 | return err; | ||
| 936 | } | ||
| 935 | 937 | ||
| 936 | kfree(p); | 938 | return p9_socket_open(client, csocket); |
| 937 | |||
| 938 | return err; | ||
| 939 | } | 939 | } |
| 940 | 940 | ||
| 941 | static int | 941 | static int |
| @@ -944,49 +944,33 @@ p9_fd_create_unix(struct p9_client *client, const char *addr, char *args) | |||
| 944 | int err; | 944 | int err; |
| 945 | struct socket *csocket; | 945 | struct socket *csocket; |
| 946 | struct sockaddr_un sun_server; | 946 | struct sockaddr_un sun_server; |
| 947 | struct p9_trans_fd *p = NULL; /* this gets allocated in p9_fd_open */ | ||
| 948 | 947 | ||
| 949 | csocket = NULL; | 948 | csocket = NULL; |
| 950 | 949 | ||
| 951 | if (strlen(addr) > UNIX_PATH_MAX) { | 950 | if (strlen(addr) > UNIX_PATH_MAX) { |
| 952 | P9_EPRINTK(KERN_ERR, "p9_trans_unix: address too long: %s\n", | 951 | P9_EPRINTK(KERN_ERR, "p9_trans_unix: address too long: %s\n", |
| 953 | addr); | 952 | addr); |
| 954 | err = -ENAMETOOLONG; | 953 | return -ENAMETOOLONG; |
| 955 | goto error; | ||
| 956 | } | 954 | } |
| 957 | 955 | ||
| 958 | sun_server.sun_family = PF_UNIX; | 956 | sun_server.sun_family = PF_UNIX; |
| 959 | strcpy(sun_server.sun_path, addr); | 957 | strcpy(sun_server.sun_path, addr); |
| 960 | sock_create_kern(PF_UNIX, SOCK_STREAM, 0, &csocket); | 958 | err = sock_create_kern(PF_UNIX, SOCK_STREAM, 0, &csocket); |
| 959 | if (err < 0) { | ||
| 960 | P9_EPRINTK(KERN_ERR, "p9_trans_unix: problem creating socket\n"); | ||
| 961 | return err; | ||
| 962 | } | ||
| 961 | err = csocket->ops->connect(csocket, (struct sockaddr *)&sun_server, | 963 | err = csocket->ops->connect(csocket, (struct sockaddr *)&sun_server, |
| 962 | sizeof(struct sockaddr_un) - 1, 0); | 964 | sizeof(struct sockaddr_un) - 1, 0); |
| 963 | if (err < 0) { | 965 | if (err < 0) { |
| 964 | P9_EPRINTK(KERN_ERR, | 966 | P9_EPRINTK(KERN_ERR, |
| 965 | "p9_trans_unix: problem connecting socket: %s: %d\n", | 967 | "p9_trans_unix: problem connecting socket: %s: %d\n", |
| 966 | addr, err); | 968 | addr, err); |
| 967 | goto error; | ||
| 968 | } | ||
| 969 | |||
| 970 | err = p9_socket_open(client, csocket); | ||
| 971 | if (err < 0) | ||
| 972 | goto error; | ||
| 973 | |||
| 974 | p = (struct p9_trans_fd *) client->trans; | ||
| 975 | p->conn = p9_conn_create(client); | ||
| 976 | if (IS_ERR(p->conn)) { | ||
| 977 | err = PTR_ERR(p->conn); | ||
| 978 | p->conn = NULL; | ||
| 979 | goto error; | ||
| 980 | } | ||
| 981 | |||
| 982 | return 0; | ||
| 983 | |||
| 984 | error: | ||
| 985 | if (csocket) | ||
| 986 | sock_release(csocket); | 969 | sock_release(csocket); |
| 970 | return err; | ||
| 971 | } | ||
| 987 | 972 | ||
| 988 | kfree(p); | 973 | return p9_socket_open(client, csocket); |
| 989 | return err; | ||
| 990 | } | 974 | } |
| 991 | 975 | ||
| 992 | static int | 976 | static int |
| @@ -994,7 +978,7 @@ p9_fd_create(struct p9_client *client, const char *addr, char *args) | |||
| 994 | { | 978 | { |
| 995 | int err; | 979 | int err; |
| 996 | struct p9_fd_opts opts; | 980 | struct p9_fd_opts opts; |
| 997 | struct p9_trans_fd *p = NULL; /* this get allocated in p9_fd_open */ | 981 | struct p9_trans_fd *p; |
| 998 | 982 | ||
| 999 | parse_opts(args, &opts); | 983 | parse_opts(args, &opts); |
| 1000 | 984 | ||
| @@ -1005,21 +989,19 @@ p9_fd_create(struct p9_client *client, const char *addr, char *args) | |||
| 1005 | 989 | ||
| 1006 | err = p9_fd_open(client, opts.rfd, opts.wfd); | 990 | err = p9_fd_open(client, opts.rfd, opts.wfd); |
| 1007 | if (err < 0) | 991 | if (err < 0) |
| 1008 | goto error; | 992 | return err; |
| 1009 | 993 | ||
| 1010 | p = (struct p9_trans_fd *) client->trans; | 994 | p = (struct p9_trans_fd *) client->trans; |
| 1011 | p->conn = p9_conn_create(client); | 995 | p->conn = p9_conn_create(client); |
| 1012 | if (IS_ERR(p->conn)) { | 996 | if (IS_ERR(p->conn)) { |
| 1013 | err = PTR_ERR(p->conn); | 997 | err = PTR_ERR(p->conn); |
| 1014 | p->conn = NULL; | 998 | p->conn = NULL; |
| 1015 | goto error; | 999 | fput(p->rd); |
| 1000 | fput(p->wr); | ||
| 1001 | return err; | ||
| 1016 | } | 1002 | } |
| 1017 | 1003 | ||
| 1018 | return 0; | 1004 | return 0; |
| 1019 | |||
| 1020 | error: | ||
| 1021 | kfree(p); | ||
| 1022 | return err; | ||
| 1023 | } | 1005 | } |
| 1024 | 1006 | ||
| 1025 | static struct p9_trans_module p9_tcp_trans = { | 1007 | static struct p9_trans_module p9_tcp_trans = { |
diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c index 65cb29db03f8..2c95a89c0f46 100644 --- a/net/9p/trans_rdma.c +++ b/net/9p/trans_rdma.c | |||
| @@ -166,7 +166,7 @@ static int parse_opts(char *params, struct p9_rdma_opts *opts) | |||
| 166 | char *p; | 166 | char *p; |
| 167 | substring_t args[MAX_OPT_ARGS]; | 167 | substring_t args[MAX_OPT_ARGS]; |
| 168 | int option; | 168 | int option; |
| 169 | char *options; | 169 | char *options, *tmp_options; |
| 170 | int ret; | 170 | int ret; |
| 171 | 171 | ||
| 172 | opts->port = P9_PORT; | 172 | opts->port = P9_PORT; |
| @@ -177,12 +177,13 @@ static int parse_opts(char *params, struct p9_rdma_opts *opts) | |||
| 177 | if (!params) | 177 | if (!params) |
| 178 | return 0; | 178 | return 0; |
| 179 | 179 | ||
| 180 | options = kstrdup(params, GFP_KERNEL); | 180 | tmp_options = kstrdup(params, GFP_KERNEL); |
| 181 | if (!options) { | 181 | if (!tmp_options) { |
| 182 | P9_DPRINTK(P9_DEBUG_ERROR, | 182 | P9_DPRINTK(P9_DEBUG_ERROR, |
| 183 | "failed to allocate copy of option string\n"); | 183 | "failed to allocate copy of option string\n"); |
| 184 | return -ENOMEM; | 184 | return -ENOMEM; |
| 185 | } | 185 | } |
| 186 | options = tmp_options; | ||
| 186 | 187 | ||
| 187 | while ((p = strsep(&options, ",")) != NULL) { | 188 | while ((p = strsep(&options, ",")) != NULL) { |
| 188 | int token; | 189 | int token; |
| @@ -216,7 +217,7 @@ static int parse_opts(char *params, struct p9_rdma_opts *opts) | |||
| 216 | } | 217 | } |
| 217 | /* RQ must be at least as large as the SQ */ | 218 | /* RQ must be at least as large as the SQ */ |
| 218 | opts->rq_depth = max(opts->rq_depth, opts->sq_depth); | 219 | opts->rq_depth = max(opts->rq_depth, opts->sq_depth); |
| 219 | kfree(options); | 220 | kfree(tmp_options); |
| 220 | return 0; | 221 | return 0; |
| 221 | } | 222 | } |
| 222 | 223 | ||
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index ea1e3daabefe..cb50f4ae5eef 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c | |||
| @@ -102,7 +102,8 @@ static void p9_virtio_close(struct p9_client *client) | |||
| 102 | struct virtio_chan *chan = client->trans; | 102 | struct virtio_chan *chan = client->trans; |
| 103 | 103 | ||
| 104 | mutex_lock(&virtio_9p_lock); | 104 | mutex_lock(&virtio_9p_lock); |
| 105 | chan->inuse = false; | 105 | if (chan) |
| 106 | chan->inuse = false; | ||
| 106 | mutex_unlock(&virtio_9p_lock); | 107 | mutex_unlock(&virtio_9p_lock); |
| 107 | } | 108 | } |
| 108 | 109 | ||
| @@ -311,6 +312,7 @@ p9_virtio_create(struct p9_client *client, const char *devname, char *args) | |||
| 311 | } | 312 | } |
| 312 | 313 | ||
| 313 | client->trans = (void *)chan; | 314 | client->trans = (void *)chan; |
| 315 | client->status = Connected; | ||
| 314 | chan->client = client; | 316 | chan->client = client; |
| 315 | 317 | ||
| 316 | return 0; | 318 | return 0; |
diff --git a/net/appletalk/aarp.c b/net/appletalk/aarp.c index 9d4adfd22757..f2b3b56aa779 100644 --- a/net/appletalk/aarp.c +++ b/net/appletalk/aarp.c | |||
| @@ -819,7 +819,7 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, | |||
| 819 | ma = &ifa->address; | 819 | ma = &ifa->address; |
| 820 | else { /* We need to make a copy of the entry. */ | 820 | else { /* We need to make a copy of the entry. */ |
| 821 | da.s_node = sa.s_node; | 821 | da.s_node = sa.s_node; |
| 822 | da.s_net = da.s_net; | 822 | da.s_net = sa.s_net; |
| 823 | ma = &da; | 823 | ma = &da; |
| 824 | } | 824 | } |
| 825 | 825 | ||
diff --git a/net/atm/br2684.c b/net/atm/br2684.c index 26a646d4eb32..c9230c398697 100644 --- a/net/atm/br2684.c +++ b/net/atm/br2684.c | |||
| @@ -554,6 +554,12 @@ static const struct net_device_ops br2684_netdev_ops = { | |||
| 554 | .ndo_validate_addr = eth_validate_addr, | 554 | .ndo_validate_addr = eth_validate_addr, |
| 555 | }; | 555 | }; |
| 556 | 556 | ||
| 557 | static const struct net_device_ops br2684_netdev_ops_routed = { | ||
| 558 | .ndo_start_xmit = br2684_start_xmit, | ||
| 559 | .ndo_set_mac_address = br2684_mac_addr, | ||
| 560 | .ndo_change_mtu = eth_change_mtu | ||
| 561 | }; | ||
| 562 | |||
| 557 | static void br2684_setup(struct net_device *netdev) | 563 | static void br2684_setup(struct net_device *netdev) |
| 558 | { | 564 | { |
| 559 | struct br2684_dev *brdev = BRPRIV(netdev); | 565 | struct br2684_dev *brdev = BRPRIV(netdev); |
| @@ -569,11 +575,10 @@ static void br2684_setup(struct net_device *netdev) | |||
| 569 | static void br2684_setup_routed(struct net_device *netdev) | 575 | static void br2684_setup_routed(struct net_device *netdev) |
| 570 | { | 576 | { |
| 571 | struct br2684_dev *brdev = BRPRIV(netdev); | 577 | struct br2684_dev *brdev = BRPRIV(netdev); |
| 572 | brdev->net_dev = netdev; | ||
| 573 | 578 | ||
| 579 | brdev->net_dev = netdev; | ||
| 574 | netdev->hard_header_len = 0; | 580 | netdev->hard_header_len = 0; |
| 575 | 581 | netdev->netdev_ops = &br2684_netdev_ops_routed; | |
| 576 | netdev->netdev_ops = &br2684_netdev_ops; | ||
| 577 | netdev->addr_len = 0; | 582 | netdev->addr_len = 0; |
| 578 | netdev->mtu = 1500; | 583 | netdev->mtu = 1500; |
| 579 | netdev->type = ARPHRD_PPP; | 584 | netdev->type = ARPHRD_PPP; |
diff --git a/net/atm/lec.c b/net/atm/lec.c index b2d644560323..42749b7b917c 100644 --- a/net/atm/lec.c +++ b/net/atm/lec.c | |||
| @@ -62,7 +62,6 @@ static int lec_open(struct net_device *dev); | |||
| 62 | static netdev_tx_t lec_start_xmit(struct sk_buff *skb, | 62 | static netdev_tx_t lec_start_xmit(struct sk_buff *skb, |
| 63 | struct net_device *dev); | 63 | struct net_device *dev); |
| 64 | static int lec_close(struct net_device *dev); | 64 | static int lec_close(struct net_device *dev); |
| 65 | static void lec_init(struct net_device *dev); | ||
| 66 | static struct lec_arp_table *lec_arp_find(struct lec_priv *priv, | 65 | static struct lec_arp_table *lec_arp_find(struct lec_priv *priv, |
| 67 | const unsigned char *mac_addr); | 66 | const unsigned char *mac_addr); |
| 68 | static int lec_arp_remove(struct lec_priv *priv, | 67 | static int lec_arp_remove(struct lec_priv *priv, |
| @@ -670,13 +669,6 @@ static const struct net_device_ops lec_netdev_ops = { | |||
| 670 | .ndo_set_multicast_list = lec_set_multicast_list, | 669 | .ndo_set_multicast_list = lec_set_multicast_list, |
| 671 | }; | 670 | }; |
| 672 | 671 | ||
| 673 | |||
| 674 | static void lec_init(struct net_device *dev) | ||
| 675 | { | ||
| 676 | dev->netdev_ops = &lec_netdev_ops; | ||
| 677 | printk("%s: Initialized!\n", dev->name); | ||
| 678 | } | ||
| 679 | |||
| 680 | static const unsigned char lec_ctrl_magic[] = { | 672 | static const unsigned char lec_ctrl_magic[] = { |
| 681 | 0xff, | 673 | 0xff, |
| 682 | 0x00, | 674 | 0x00, |
| @@ -893,6 +885,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg) | |||
| 893 | dev_lec[i] = alloc_etherdev(size); | 885 | dev_lec[i] = alloc_etherdev(size); |
| 894 | if (!dev_lec[i]) | 886 | if (!dev_lec[i]) |
| 895 | return -ENOMEM; | 887 | return -ENOMEM; |
| 888 | dev_lec[i]->netdev_ops = &lec_netdev_ops; | ||
| 896 | snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i); | 889 | snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i); |
| 897 | if (register_netdev(dev_lec[i])) { | 890 | if (register_netdev(dev_lec[i])) { |
| 898 | free_netdev(dev_lec[i]); | 891 | free_netdev(dev_lec[i]); |
| @@ -901,7 +894,6 @@ static int lecd_attach(struct atm_vcc *vcc, int arg) | |||
| 901 | 894 | ||
| 902 | priv = netdev_priv(dev_lec[i]); | 895 | priv = netdev_priv(dev_lec[i]); |
| 903 | priv->is_trdev = is_trdev; | 896 | priv->is_trdev = is_trdev; |
| 904 | lec_init(dev_lec[i]); | ||
| 905 | } else { | 897 | } else { |
| 906 | priv = netdev_priv(dev_lec[i]); | 898 | priv = netdev_priv(dev_lec[i]); |
| 907 | if (priv->lecd) | 899 | if (priv->lecd) |
diff --git a/net/ax25/ax25_out.c b/net/ax25/ax25_out.c index bf706f83a5c9..14912600ec57 100644 --- a/net/ax25/ax25_out.c +++ b/net/ax25/ax25_out.c | |||
| @@ -92,6 +92,12 @@ ax25_cb *ax25_send_frame(struct sk_buff *skb, int paclen, ax25_address *src, ax2 | |||
| 92 | #endif | 92 | #endif |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | /* | ||
| 96 | * There is one ref for the state machine; a caller needs | ||
| 97 | * one more to put it back, just like with the existing one. | ||
| 98 | */ | ||
| 99 | ax25_cb_hold(ax25); | ||
| 100 | |||
| 95 | ax25_cb_add(ax25); | 101 | ax25_cb_add(ax25); |
| 96 | 102 | ||
| 97 | ax25->state = AX25_STATE_1; | 103 | ax25->state = AX25_STATE_1; |
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index 29b1b220d6cf..ef09c7b3a858 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c | |||
| @@ -78,7 +78,7 @@ static struct bnep_session *__bnep_get_session(u8 *dst) | |||
| 78 | static void __bnep_link_session(struct bnep_session *s) | 78 | static void __bnep_link_session(struct bnep_session *s) |
| 79 | { | 79 | { |
| 80 | /* It's safe to call __module_get() here because sessions are added | 80 | /* It's safe to call __module_get() here because sessions are added |
| 81 | by the socket layer which has to hold the refference to this module. | 81 | by the socket layer which has to hold the reference to this module. |
| 82 | */ | 82 | */ |
| 83 | __module_get(THIS_MODULE); | 83 | __module_get(THIS_MODULE); |
| 84 | list_add(&s->list, &bnep_session_list); | 84 | list_add(&s->list, &bnep_session_list); |
| @@ -632,7 +632,7 @@ int bnep_del_connection(struct bnep_conndel_req *req) | |||
| 632 | s = __bnep_get_session(req->dst); | 632 | s = __bnep_get_session(req->dst); |
| 633 | if (s) { | 633 | if (s) { |
| 634 | /* Wakeup user-space which is polling for socket errors. | 634 | /* Wakeup user-space which is polling for socket errors. |
| 635 | * This is temporary hack untill we have shutdown in L2CAP */ | 635 | * This is temporary hack until we have shutdown in L2CAP */ |
| 636 | s->sock->sk->sk_err = EUNATCH; | 636 | s->sock->sk->sk_err = EUNATCH; |
| 637 | 637 | ||
| 638 | /* Kill session thread */ | 638 | /* Kill session thread */ |
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index b7c4224f4e7d..b10e3cdb08f8 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
| @@ -377,6 +377,9 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 | |||
| 377 | 377 | ||
| 378 | if (acl->state == BT_CONNECTED && | 378 | if (acl->state == BT_CONNECTED && |
| 379 | (sco->state == BT_OPEN || sco->state == BT_CLOSED)) { | 379 | (sco->state == BT_OPEN || sco->state == BT_CLOSED)) { |
| 380 | acl->power_save = 1; | ||
| 381 | hci_conn_enter_active_mode(acl); | ||
| 382 | |||
| 380 | if (lmp_esco_capable(hdev)) | 383 | if (lmp_esco_capable(hdev)) |
| 381 | hci_setup_sync(sco, acl->handle); | 384 | hci_setup_sync(sco, acl->handle); |
| 382 | else | 385 | else |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 28517bad796c..592da5c909c1 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
| @@ -1699,6 +1699,7 @@ static inline void hci_sync_conn_complete_evt(struct hci_dev *hdev, struct sk_bu | |||
| 1699 | break; | 1699 | break; |
| 1700 | 1700 | ||
| 1701 | case 0x1c: /* SCO interval rejected */ | 1701 | case 0x1c: /* SCO interval rejected */ |
| 1702 | case 0x1a: /* Unsupported Remote Feature */ | ||
| 1702 | case 0x1f: /* Unspecified error */ | 1703 | case 0x1f: /* Unspecified error */ |
| 1703 | if (conn->out && conn->attempt < 2) { | 1704 | if (conn->out && conn->attempt < 2) { |
| 1704 | conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | | 1705 | conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | |
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 569750010fd3..280529ad9274 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c | |||
| @@ -243,6 +243,39 @@ static void hidp_input_report(struct hidp_session *session, struct sk_buff *skb) | |||
| 243 | input_sync(dev); | 243 | input_sync(dev); |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | static int __hidp_send_ctrl_message(struct hidp_session *session, | ||
| 247 | unsigned char hdr, unsigned char *data, int size) | ||
| 248 | { | ||
| 249 | struct sk_buff *skb; | ||
| 250 | |||
| 251 | BT_DBG("session %p data %p size %d", session, data, size); | ||
| 252 | |||
| 253 | if (!(skb = alloc_skb(size + 1, GFP_ATOMIC))) { | ||
| 254 | BT_ERR("Can't allocate memory for new frame"); | ||
| 255 | return -ENOMEM; | ||
| 256 | } | ||
| 257 | |||
| 258 | *skb_put(skb, 1) = hdr; | ||
| 259 | if (data && size > 0) | ||
| 260 | memcpy(skb_put(skb, size), data, size); | ||
| 261 | |||
| 262 | skb_queue_tail(&session->ctrl_transmit, skb); | ||
| 263 | |||
| 264 | return 0; | ||
| 265 | } | ||
| 266 | |||
| 267 | static inline int hidp_send_ctrl_message(struct hidp_session *session, | ||
| 268 | unsigned char hdr, unsigned char *data, int size) | ||
| 269 | { | ||
| 270 | int err; | ||
| 271 | |||
| 272 | err = __hidp_send_ctrl_message(session, hdr, data, size); | ||
| 273 | |||
| 274 | hidp_schedule(session); | ||
| 275 | |||
| 276 | return err; | ||
| 277 | } | ||
| 278 | |||
| 246 | static int hidp_queue_report(struct hidp_session *session, | 279 | static int hidp_queue_report(struct hidp_session *session, |
| 247 | unsigned char *data, int size) | 280 | unsigned char *data, int size) |
| 248 | { | 281 | { |
| @@ -280,9 +313,22 @@ static int hidp_send_report(struct hidp_session *session, struct hid_report *rep | |||
| 280 | return hidp_queue_report(session, buf, rsize); | 313 | return hidp_queue_report(session, buf, rsize); |
| 281 | } | 314 | } |
| 282 | 315 | ||
| 283 | static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count) | 316 | static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count, |
| 317 | unsigned char report_type) | ||
| 284 | { | 318 | { |
| 285 | if (hidp_queue_report(hid->driver_data, data, count)) | 319 | switch (report_type) { |
| 320 | case HID_FEATURE_REPORT: | ||
| 321 | report_type = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE; | ||
| 322 | break; | ||
| 323 | case HID_OUTPUT_REPORT: | ||
| 324 | report_type = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT; | ||
| 325 | break; | ||
| 326 | default: | ||
| 327 | return -EINVAL; | ||
| 328 | } | ||
| 329 | |||
| 330 | if (hidp_send_ctrl_message(hid->driver_data, report_type, | ||
| 331 | data, count)) | ||
| 286 | return -ENOMEM; | 332 | return -ENOMEM; |
| 287 | return count; | 333 | return count; |
| 288 | } | 334 | } |
| @@ -307,39 +353,6 @@ static inline void hidp_del_timer(struct hidp_session *session) | |||
| 307 | del_timer(&session->timer); | 353 | del_timer(&session->timer); |
| 308 | } | 354 | } |
| 309 | 355 | ||
| 310 | static int __hidp_send_ctrl_message(struct hidp_session *session, | ||
| 311 | unsigned char hdr, unsigned char *data, int size) | ||
| 312 | { | ||
| 313 | struct sk_buff *skb; | ||
| 314 | |||
| 315 | BT_DBG("session %p data %p size %d", session, data, size); | ||
| 316 | |||
| 317 | if (!(skb = alloc_skb(size + 1, GFP_ATOMIC))) { | ||
| 318 | BT_ERR("Can't allocate memory for new frame"); | ||
| 319 | return -ENOMEM; | ||
| 320 | } | ||
| 321 | |||
| 322 | *skb_put(skb, 1) = hdr; | ||
| 323 | if (data && size > 0) | ||
| 324 | memcpy(skb_put(skb, size), data, size); | ||
| 325 | |||
| 326 | skb_queue_tail(&session->ctrl_transmit, skb); | ||
| 327 | |||
| 328 | return 0; | ||
| 329 | } | ||
| 330 | |||
| 331 | static inline int hidp_send_ctrl_message(struct hidp_session *session, | ||
| 332 | unsigned char hdr, unsigned char *data, int size) | ||
| 333 | { | ||
| 334 | int err; | ||
| 335 | |||
| 336 | err = __hidp_send_ctrl_message(session, hdr, data, size); | ||
| 337 | |||
| 338 | hidp_schedule(session); | ||
| 339 | |||
| 340 | return err; | ||
| 341 | } | ||
| 342 | |||
| 343 | static void hidp_process_handshake(struct hidp_session *session, | 356 | static void hidp_process_handshake(struct hidp_session *session, |
| 344 | unsigned char param) | 357 | unsigned char param) |
| 345 | { | 358 | { |
| @@ -701,29 +714,9 @@ static void hidp_close(struct hid_device *hid) | |||
| 701 | static int hidp_parse(struct hid_device *hid) | 714 | static int hidp_parse(struct hid_device *hid) |
| 702 | { | 715 | { |
| 703 | struct hidp_session *session = hid->driver_data; | 716 | struct hidp_session *session = hid->driver_data; |
| 704 | struct hidp_connadd_req *req = session->req; | ||
| 705 | unsigned char *buf; | ||
| 706 | int ret; | ||
| 707 | |||
| 708 | buf = kmalloc(req->rd_size, GFP_KERNEL); | ||
| 709 | if (!buf) | ||
| 710 | return -ENOMEM; | ||
| 711 | |||
| 712 | if (copy_from_user(buf, req->rd_data, req->rd_size)) { | ||
| 713 | kfree(buf); | ||
| 714 | return -EFAULT; | ||
| 715 | } | ||
| 716 | |||
| 717 | ret = hid_parse_report(session->hid, buf, req->rd_size); | ||
| 718 | |||
| 719 | kfree(buf); | ||
| 720 | |||
| 721 | if (ret) | ||
| 722 | return ret; | ||
| 723 | |||
| 724 | session->req = NULL; | ||
| 725 | 717 | ||
| 726 | return 0; | 718 | return hid_parse_report(session->hid, session->rd_data, |
| 719 | session->rd_size); | ||
| 727 | } | 720 | } |
| 728 | 721 | ||
| 729 | static int hidp_start(struct hid_device *hid) | 722 | static int hidp_start(struct hid_device *hid) |
| @@ -768,12 +761,24 @@ static int hidp_setup_hid(struct hidp_session *session, | |||
| 768 | bdaddr_t src, dst; | 761 | bdaddr_t src, dst; |
| 769 | int err; | 762 | int err; |
| 770 | 763 | ||
| 764 | session->rd_data = kzalloc(req->rd_size, GFP_KERNEL); | ||
| 765 | if (!session->rd_data) | ||
| 766 | return -ENOMEM; | ||
| 767 | |||
| 768 | if (copy_from_user(session->rd_data, req->rd_data, req->rd_size)) { | ||
| 769 | err = -EFAULT; | ||
| 770 | goto fault; | ||
| 771 | } | ||
| 772 | session->rd_size = req->rd_size; | ||
| 773 | |||
| 771 | hid = hid_allocate_device(); | 774 | hid = hid_allocate_device(); |
| 772 | if (IS_ERR(hid)) | 775 | if (IS_ERR(hid)) { |
| 773 | return PTR_ERR(session->hid); | 776 | err = PTR_ERR(hid); |
| 777 | goto fault; | ||
| 778 | } | ||
| 774 | 779 | ||
| 775 | session->hid = hid; | 780 | session->hid = hid; |
| 776 | session->req = req; | 781 | |
| 777 | hid->driver_data = session; | 782 | hid->driver_data = session; |
| 778 | 783 | ||
| 779 | baswap(&src, &bt_sk(session->ctrl_sock->sk)->src); | 784 | baswap(&src, &bt_sk(session->ctrl_sock->sk)->src); |
| @@ -804,6 +809,10 @@ failed: | |||
| 804 | hid_destroy_device(hid); | 809 | hid_destroy_device(hid); |
| 805 | session->hid = NULL; | 810 | session->hid = NULL; |
| 806 | 811 | ||
| 812 | fault: | ||
| 813 | kfree(session->rd_data); | ||
| 814 | session->rd_data = NULL; | ||
| 815 | |||
| 807 | return err; | 816 | return err; |
| 808 | } | 817 | } |
| 809 | 818 | ||
| @@ -898,6 +907,9 @@ unlink: | |||
| 898 | session->hid = NULL; | 907 | session->hid = NULL; |
| 899 | } | 908 | } |
| 900 | 909 | ||
| 910 | kfree(session->rd_data); | ||
| 911 | session->rd_data = NULL; | ||
| 912 | |||
| 901 | purge: | 913 | purge: |
| 902 | skb_queue_purge(&session->ctrl_transmit); | 914 | skb_queue_purge(&session->ctrl_transmit); |
| 903 | skb_queue_purge(&session->intr_transmit); | 915 | skb_queue_purge(&session->intr_transmit); |
diff --git a/net/bluetooth/hidp/hidp.h b/net/bluetooth/hidp/hidp.h index faf3d74c3586..a4e215d50c10 100644 --- a/net/bluetooth/hidp/hidp.h +++ b/net/bluetooth/hidp/hidp.h | |||
| @@ -154,7 +154,9 @@ struct hidp_session { | |||
| 154 | struct sk_buff_head ctrl_transmit; | 154 | struct sk_buff_head ctrl_transmit; |
| 155 | struct sk_buff_head intr_transmit; | 155 | struct sk_buff_head intr_transmit; |
| 156 | 156 | ||
| 157 | struct hidp_connadd_req *req; | 157 | /* Report descriptor */ |
| 158 | __u8 *rd_data; | ||
| 159 | uint rd_size; | ||
| 158 | }; | 160 | }; |
| 159 | 161 | ||
| 160 | static inline void hidp_schedule(struct hidp_session *session) | 162 | static inline void hidp_schedule(struct hidp_session *session) |
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index 5129b88c8e5b..400efa26ddba 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
| @@ -1212,6 +1212,7 @@ static void l2cap_monitor_timeout(unsigned long arg) | |||
| 1212 | bh_lock_sock(sk); | 1212 | bh_lock_sock(sk); |
| 1213 | if (l2cap_pi(sk)->retry_count >= l2cap_pi(sk)->remote_max_tx) { | 1213 | if (l2cap_pi(sk)->retry_count >= l2cap_pi(sk)->remote_max_tx) { |
| 1214 | l2cap_send_disconn_req(l2cap_pi(sk)->conn, sk); | 1214 | l2cap_send_disconn_req(l2cap_pi(sk)->conn, sk); |
| 1215 | bh_unlock_sock(sk); | ||
| 1215 | return; | 1216 | return; |
| 1216 | } | 1217 | } |
| 1217 | 1218 | ||
| @@ -1367,7 +1368,6 @@ static int l2cap_ertm_send(struct sock *sk) | |||
| 1367 | 1368 | ||
| 1368 | while ((skb = sk->sk_send_head) && (!l2cap_tx_window_full(sk)) && | 1369 | while ((skb = sk->sk_send_head) && (!l2cap_tx_window_full(sk)) && |
| 1369 | !(pi->conn_state & L2CAP_CONN_REMOTE_BUSY)) { | 1370 | !(pi->conn_state & L2CAP_CONN_REMOTE_BUSY)) { |
| 1370 | tx_skb = skb_clone(skb, GFP_ATOMIC); | ||
| 1371 | 1371 | ||
| 1372 | if (pi->remote_max_tx && | 1372 | if (pi->remote_max_tx && |
| 1373 | bt_cb(skb)->retries == pi->remote_max_tx) { | 1373 | bt_cb(skb)->retries == pi->remote_max_tx) { |
| @@ -1375,6 +1375,8 @@ static int l2cap_ertm_send(struct sock *sk) | |||
| 1375 | break; | 1375 | break; |
| 1376 | } | 1376 | } |
| 1377 | 1377 | ||
| 1378 | tx_skb = skb_clone(skb, GFP_ATOMIC); | ||
| 1379 | |||
| 1378 | bt_cb(skb)->retries++; | 1380 | bt_cb(skb)->retries++; |
| 1379 | 1381 | ||
| 1380 | control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); | 1382 | control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); |
| @@ -3435,8 +3437,8 @@ static inline int l2cap_data_channel_sframe(struct sock *sk, u16 rx_control, str | |||
| 3435 | (pi->unacked_frames > 0)) | 3437 | (pi->unacked_frames > 0)) |
| 3436 | __mod_retrans_timer(); | 3438 | __mod_retrans_timer(); |
| 3437 | 3439 | ||
| 3438 | l2cap_ertm_send(sk); | ||
| 3439 | pi->conn_state &= ~L2CAP_CONN_REMOTE_BUSY; | 3440 | pi->conn_state &= ~L2CAP_CONN_REMOTE_BUSY; |
| 3441 | l2cap_ertm_send(sk); | ||
| 3440 | } | 3442 | } |
| 3441 | break; | 3443 | break; |
| 3442 | 3444 | ||
| @@ -3471,9 +3473,9 @@ static inline int l2cap_data_channel_sframe(struct sock *sk, u16 rx_control, str | |||
| 3471 | pi->conn_state &= ~L2CAP_CONN_REMOTE_BUSY; | 3473 | pi->conn_state &= ~L2CAP_CONN_REMOTE_BUSY; |
| 3472 | 3474 | ||
| 3473 | if (rx_control & L2CAP_CTRL_POLL) { | 3475 | if (rx_control & L2CAP_CTRL_POLL) { |
| 3474 | l2cap_retransmit_frame(sk, tx_seq); | ||
| 3475 | pi->expected_ack_seq = tx_seq; | 3476 | pi->expected_ack_seq = tx_seq; |
| 3476 | l2cap_drop_acked_frames(sk); | 3477 | l2cap_drop_acked_frames(sk); |
| 3478 | l2cap_retransmit_frame(sk, tx_seq); | ||
| 3477 | l2cap_ertm_send(sk); | 3479 | l2cap_ertm_send(sk); |
| 3478 | if (pi->conn_state & L2CAP_CONN_WAIT_F) { | 3480 | if (pi->conn_state & L2CAP_CONN_WAIT_F) { |
| 3479 | pi->srej_save_reqseq = tx_seq; | 3481 | pi->srej_save_reqseq = tx_seq; |
| @@ -3517,7 +3519,6 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk | |||
| 3517 | struct l2cap_pinfo *pi; | 3519 | struct l2cap_pinfo *pi; |
| 3518 | u16 control, len; | 3520 | u16 control, len; |
| 3519 | u8 tx_seq; | 3521 | u8 tx_seq; |
| 3520 | int err; | ||
| 3521 | 3522 | ||
| 3522 | sk = l2cap_get_chan_by_scid(&conn->chan_list, cid); | 3523 | sk = l2cap_get_chan_by_scid(&conn->chan_list, cid); |
| 3523 | if (!sk) { | 3524 | if (!sk) { |
| @@ -3569,13 +3570,11 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk | |||
| 3569 | goto drop; | 3570 | goto drop; |
| 3570 | 3571 | ||
| 3571 | if (__is_iframe(control)) | 3572 | if (__is_iframe(control)) |
| 3572 | err = l2cap_data_channel_iframe(sk, control, skb); | 3573 | l2cap_data_channel_iframe(sk, control, skb); |
| 3573 | else | 3574 | else |
| 3574 | err = l2cap_data_channel_sframe(sk, control, skb); | 3575 | l2cap_data_channel_sframe(sk, control, skb); |
| 3575 | 3576 | ||
| 3576 | if (!err) | 3577 | goto done; |
| 3577 | goto done; | ||
| 3578 | break; | ||
| 3579 | 3578 | ||
| 3580 | case L2CAP_MODE_STREAMING: | 3579 | case L2CAP_MODE_STREAMING: |
| 3581 | control = get_unaligned_le16(skb->data); | 3580 | control = get_unaligned_le16(skb->data); |
| @@ -3601,7 +3600,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk | |||
| 3601 | else | 3600 | else |
| 3602 | pi->expected_tx_seq = tx_seq + 1; | 3601 | pi->expected_tx_seq = tx_seq + 1; |
| 3603 | 3602 | ||
| 3604 | err = l2cap_sar_reassembly_sdu(sk, skb, control); | 3603 | l2cap_sar_reassembly_sdu(sk, skb, control); |
| 3605 | 3604 | ||
| 3606 | goto done; | 3605 | goto done; |
| 3607 | 3606 | ||
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index fc5ee3296e22..89f4a59eb82b 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
| @@ -252,7 +252,6 @@ static void rfcomm_session_timeout(unsigned long arg) | |||
| 252 | BT_DBG("session %p state %ld", s, s->state); | 252 | BT_DBG("session %p state %ld", s, s->state); |
| 253 | 253 | ||
| 254 | set_bit(RFCOMM_TIMED_OUT, &s->flags); | 254 | set_bit(RFCOMM_TIMED_OUT, &s->flags); |
| 255 | rfcomm_session_put(s); | ||
| 256 | rfcomm_schedule(RFCOMM_SCHED_TIMEO); | 255 | rfcomm_schedule(RFCOMM_SCHED_TIMEO); |
| 257 | } | 256 | } |
| 258 | 257 | ||
| @@ -1151,7 +1150,11 @@ static int rfcomm_recv_ua(struct rfcomm_session *s, u8 dlci) | |||
| 1151 | break; | 1150 | break; |
| 1152 | 1151 | ||
| 1153 | case BT_DISCONN: | 1152 | case BT_DISCONN: |
| 1154 | rfcomm_session_put(s); | 1153 | /* When socket is closed and we are not RFCOMM |
| 1154 | * initiator rfcomm_process_rx already calls | ||
| 1155 | * rfcomm_session_put() */ | ||
| 1156 | if (s->sock->sk->sk_state != BT_CLOSED) | ||
| 1157 | rfcomm_session_put(s); | ||
| 1155 | break; | 1158 | break; |
| 1156 | } | 1159 | } |
| 1157 | } | 1160 | } |
| @@ -1920,6 +1923,7 @@ static inline void rfcomm_process_sessions(void) | |||
| 1920 | if (test_and_clear_bit(RFCOMM_TIMED_OUT, &s->flags)) { | 1923 | if (test_and_clear_bit(RFCOMM_TIMED_OUT, &s->flags)) { |
| 1921 | s->state = BT_DISCONN; | 1924 | s->state = BT_DISCONN; |
| 1922 | rfcomm_send_disc(s, 0); | 1925 | rfcomm_send_disc(s, 0); |
| 1926 | rfcomm_session_put(s); | ||
| 1923 | continue; | 1927 | continue; |
| 1924 | } | 1928 | } |
| 1925 | 1929 | ||
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index bd1c65425d4f..0b7f262cd148 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c | |||
| @@ -1406,6 +1406,9 @@ static int do_ebt_set_ctl(struct sock *sk, | |||
| 1406 | { | 1406 | { |
| 1407 | int ret; | 1407 | int ret; |
| 1408 | 1408 | ||
| 1409 | if (!capable(CAP_NET_ADMIN)) | ||
| 1410 | return -EPERM; | ||
| 1411 | |||
| 1409 | switch(cmd) { | 1412 | switch(cmd) { |
| 1410 | case EBT_SO_SET_ENTRIES: | 1413 | case EBT_SO_SET_ENTRIES: |
| 1411 | ret = do_replace(sock_net(sk), user, len); | 1414 | ret = do_replace(sock_net(sk), user, len); |
| @@ -1425,6 +1428,9 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) | |||
| 1425 | struct ebt_replace tmp; | 1428 | struct ebt_replace tmp; |
| 1426 | struct ebt_table *t; | 1429 | struct ebt_table *t; |
| 1427 | 1430 | ||
| 1431 | if (!capable(CAP_NET_ADMIN)) | ||
| 1432 | return -EPERM; | ||
| 1433 | |||
| 1428 | if (copy_from_user(&tmp, user, sizeof(tmp))) | 1434 | if (copy_from_user(&tmp, user, sizeof(tmp))) |
| 1429 | return -EFAULT; | 1435 | return -EFAULT; |
| 1430 | 1436 | ||
diff --git a/net/compat.c b/net/compat.c index e1a56ade803b..a1fb1b079a82 100644 --- a/net/compat.c +++ b/net/compat.c | |||
| @@ -754,26 +754,21 @@ asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, size_t len, | |||
| 754 | 754 | ||
| 755 | asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg, | 755 | asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg, |
| 756 | unsigned vlen, unsigned int flags, | 756 | unsigned vlen, unsigned int flags, |
| 757 | struct timespec __user *timeout) | 757 | struct compat_timespec __user *timeout) |
| 758 | { | 758 | { |
| 759 | int datagrams; | 759 | int datagrams; |
| 760 | struct timespec ktspec; | 760 | struct timespec ktspec; |
| 761 | struct compat_timespec __user *utspec; | ||
| 762 | 761 | ||
| 763 | if (timeout == NULL) | 762 | if (timeout == NULL) |
| 764 | return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen, | 763 | return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen, |
| 765 | flags | MSG_CMSG_COMPAT, NULL); | 764 | flags | MSG_CMSG_COMPAT, NULL); |
| 766 | 765 | ||
| 767 | utspec = (struct compat_timespec __user *)timeout; | 766 | if (get_compat_timespec(&ktspec, timeout)) |
| 768 | if (get_user(ktspec.tv_sec, &utspec->tv_sec) || | ||
| 769 | get_user(ktspec.tv_nsec, &utspec->tv_nsec)) | ||
| 770 | return -EFAULT; | 767 | return -EFAULT; |
| 771 | 768 | ||
| 772 | datagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen, | 769 | datagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen, |
| 773 | flags | MSG_CMSG_COMPAT, &ktspec); | 770 | flags | MSG_CMSG_COMPAT, &ktspec); |
| 774 | if (datagrams > 0 && | 771 | if (datagrams > 0 && put_compat_timespec(&ktspec, timeout)) |
| 775 | (put_user(ktspec.tv_sec, &utspec->tv_sec) || | ||
| 776 | put_user(ktspec.tv_nsec, &utspec->tv_nsec))) | ||
| 777 | datagrams = -EFAULT; | 772 | datagrams = -EFAULT; |
| 778 | 773 | ||
| 779 | return datagrams; | 774 | return datagrams; |
diff --git a/net/core/dev.c b/net/core/dev.c index c36a17aafcf3..bb1f1da2b8a7 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
| @@ -2041,7 +2041,7 @@ gso: | |||
| 2041 | rcu_read_lock_bh(); | 2041 | rcu_read_lock_bh(); |
| 2042 | 2042 | ||
| 2043 | txq = dev_pick_tx(dev, skb); | 2043 | txq = dev_pick_tx(dev, skb); |
| 2044 | q = rcu_dereference(txq->qdisc); | 2044 | q = rcu_dereference_bh(txq->qdisc); |
| 2045 | 2045 | ||
| 2046 | #ifdef CONFIG_NET_CLS_ACT | 2046 | #ifdef CONFIG_NET_CLS_ACT |
| 2047 | skb->tc_verd = SET_TC_AT(skb->tc_verd, AT_EGRESS); | 2047 | skb->tc_verd = SET_TC_AT(skb->tc_verd, AT_EGRESS); |
| @@ -2761,7 +2761,7 @@ gro_result_t napi_frags_finish(struct napi_struct *napi, struct sk_buff *skb, | |||
| 2761 | switch (ret) { | 2761 | switch (ret) { |
| 2762 | case GRO_NORMAL: | 2762 | case GRO_NORMAL: |
| 2763 | case GRO_HELD: | 2763 | case GRO_HELD: |
| 2764 | skb->protocol = eth_type_trans(skb, napi->dev); | 2764 | skb->protocol = eth_type_trans(skb, skb->dev); |
| 2765 | 2765 | ||
| 2766 | if (ret == GRO_HELD) | 2766 | if (ret == GRO_HELD) |
| 2767 | skb_gro_pull(skb, -ETH_HLEN); | 2767 | skb_gro_pull(skb, -ETH_HLEN); |
| @@ -4771,21 +4771,23 @@ static void net_set_todo(struct net_device *dev) | |||
| 4771 | 4771 | ||
| 4772 | static void rollback_registered_many(struct list_head *head) | 4772 | static void rollback_registered_many(struct list_head *head) |
| 4773 | { | 4773 | { |
| 4774 | struct net_device *dev; | 4774 | struct net_device *dev, *tmp; |
| 4775 | 4775 | ||
| 4776 | BUG_ON(dev_boot_phase); | 4776 | BUG_ON(dev_boot_phase); |
| 4777 | ASSERT_RTNL(); | 4777 | ASSERT_RTNL(); |
| 4778 | 4778 | ||
| 4779 | list_for_each_entry(dev, head, unreg_list) { | 4779 | list_for_each_entry_safe(dev, tmp, head, unreg_list) { |
| 4780 | /* Some devices call without registering | 4780 | /* Some devices call without registering |
| 4781 | * for initialization unwind. | 4781 | * for initialization unwind. Remove those |
| 4782 | * devices and proceed with the remaining. | ||
| 4782 | */ | 4783 | */ |
| 4783 | if (dev->reg_state == NETREG_UNINITIALIZED) { | 4784 | if (dev->reg_state == NETREG_UNINITIALIZED) { |
| 4784 | pr_debug("unregister_netdevice: device %s/%p never " | 4785 | pr_debug("unregister_netdevice: device %s/%p never " |
| 4785 | "was registered\n", dev->name, dev); | 4786 | "was registered\n", dev->name, dev); |
| 4786 | 4787 | ||
| 4787 | WARN_ON(1); | 4788 | WARN_ON(1); |
| 4788 | return; | 4789 | list_del(&dev->unreg_list); |
| 4790 | continue; | ||
| 4789 | } | 4791 | } |
| 4790 | 4792 | ||
| 4791 | BUG_ON(dev->reg_state != NETREG_REGISTERED); | 4793 | BUG_ON(dev->reg_state != NETREG_REGISTERED); |
| @@ -5033,6 +5035,11 @@ int register_netdevice(struct net_device *dev) | |||
| 5033 | rollback_registered(dev); | 5035 | rollback_registered(dev); |
| 5034 | dev->reg_state = NETREG_UNREGISTERED; | 5036 | dev->reg_state = NETREG_UNREGISTERED; |
| 5035 | } | 5037 | } |
| 5038 | /* | ||
| 5039 | * Prevent userspace races by waiting until the network | ||
| 5040 | * device is fully setup before sending notifications. | ||
| 5041 | */ | ||
| 5042 | rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U); | ||
| 5036 | 5043 | ||
| 5037 | out: | 5044 | out: |
| 5038 | return ret; | 5045 | return ret; |
| @@ -5595,6 +5602,12 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char | |||
| 5595 | /* Notify protocols, that a new device appeared. */ | 5602 | /* Notify protocols, that a new device appeared. */ |
| 5596 | call_netdevice_notifiers(NETDEV_REGISTER, dev); | 5603 | call_netdevice_notifiers(NETDEV_REGISTER, dev); |
| 5597 | 5604 | ||
| 5605 | /* | ||
| 5606 | * Prevent userspace races by waiting until the network | ||
| 5607 | * device is fully setup before sending notifications. | ||
| 5608 | */ | ||
| 5609 | rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U); | ||
| 5610 | |||
| 5598 | synchronize_net(); | 5611 | synchronize_net(); |
| 5599 | err = 0; | 5612 | err = 0; |
| 5600 | out: | 5613 | out: |
diff --git a/net/core/dst.c b/net/core/dst.c index 57bc4d5b8d08..cb1b3488b739 100644 --- a/net/core/dst.c +++ b/net/core/dst.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <linux/string.h> | 17 | #include <linux/string.h> |
| 18 | #include <linux/types.h> | 18 | #include <linux/types.h> |
| 19 | #include <net/net_namespace.h> | 19 | #include <net/net_namespace.h> |
| 20 | #include <linux/sched.h> | ||
| 20 | 21 | ||
| 21 | #include <net/dst.h> | 22 | #include <net/dst.h> |
| 22 | 23 | ||
| @@ -79,6 +80,7 @@ loop: | |||
| 79 | while ((dst = next) != NULL) { | 80 | while ((dst = next) != NULL) { |
| 80 | next = dst->next; | 81 | next = dst->next; |
| 81 | prefetch(&next->next); | 82 | prefetch(&next->next); |
| 83 | cond_resched(); | ||
| 82 | if (likely(atomic_read(&dst->__refcnt))) { | 84 | if (likely(atomic_read(&dst->__refcnt))) { |
| 83 | last->next = dst; | 85 | last->next = dst; |
| 84 | last = dst; | 86 | last = dst; |
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index d8aee584e8d1..236a9988ea91 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
| @@ -927,6 +927,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr) | |||
| 927 | case ETHTOOL_GPERMADDR: | 927 | case ETHTOOL_GPERMADDR: |
| 928 | case ETHTOOL_GUFO: | 928 | case ETHTOOL_GUFO: |
| 929 | case ETHTOOL_GGSO: | 929 | case ETHTOOL_GGSO: |
| 930 | case ETHTOOL_GGRO: | ||
| 930 | case ETHTOOL_GFLAGS: | 931 | case ETHTOOL_GFLAGS: |
| 931 | case ETHTOOL_GPFLAGS: | 932 | case ETHTOOL_GPFLAGS: |
| 932 | case ETHTOOL_GRXFH: | 933 | case ETHTOOL_GRXFH: |
diff --git a/net/core/filter.c b/net/core/filter.c index 08db7b9143a3..3541aa48d21d 100644 --- a/net/core/filter.c +++ b/net/core/filter.c | |||
| @@ -86,7 +86,7 @@ int sk_filter(struct sock *sk, struct sk_buff *skb) | |||
| 86 | return err; | 86 | return err; |
| 87 | 87 | ||
| 88 | rcu_read_lock_bh(); | 88 | rcu_read_lock_bh(); |
| 89 | filter = rcu_dereference(sk->sk_filter); | 89 | filter = rcu_dereference_bh(sk->sk_filter); |
| 90 | if (filter) { | 90 | if (filter) { |
| 91 | unsigned int pkt_len = sk_run_filter(skb, filter->insns, | 91 | unsigned int pkt_len = sk_run_filter(skb, filter->insns, |
| 92 | filter->len); | 92 | filter->len); |
| @@ -521,7 +521,7 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk) | |||
| 521 | } | 521 | } |
| 522 | 522 | ||
| 523 | rcu_read_lock_bh(); | 523 | rcu_read_lock_bh(); |
| 524 | old_fp = rcu_dereference(sk->sk_filter); | 524 | old_fp = rcu_dereference_bh(sk->sk_filter); |
| 525 | rcu_assign_pointer(sk->sk_filter, fp); | 525 | rcu_assign_pointer(sk->sk_filter, fp); |
| 526 | rcu_read_unlock_bh(); | 526 | rcu_read_unlock_bh(); |
| 527 | 527 | ||
| @@ -536,7 +536,7 @@ int sk_detach_filter(struct sock *sk) | |||
| 536 | struct sk_filter *filter; | 536 | struct sk_filter *filter; |
| 537 | 537 | ||
| 538 | rcu_read_lock_bh(); | 538 | rcu_read_lock_bh(); |
| 539 | filter = rcu_dereference(sk->sk_filter); | 539 | filter = rcu_dereference_bh(sk->sk_filter); |
| 540 | if (filter) { | 540 | if (filter) { |
| 541 | rcu_assign_pointer(sk->sk_filter, NULL); | 541 | rcu_assign_pointer(sk->sk_filter, NULL); |
| 542 | sk_filter_delayed_uncharge(sk, filter); | 542 | sk_filter_delayed_uncharge(sk, filter); |
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index fbc1c7472c5e..099c753c4213 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
| @@ -410,7 +410,8 @@ static ssize_t wireless_show(struct device *d, char *buf, | |||
| 410 | const struct iw_statistics *iw; | 410 | const struct iw_statistics *iw; |
| 411 | ssize_t ret = -EINVAL; | 411 | ssize_t ret = -EINVAL; |
| 412 | 412 | ||
| 413 | rtnl_lock(); | 413 | if (!rtnl_trylock()) |
| 414 | return restart_syscall(); | ||
| 414 | if (dev_isalive(dev)) { | 415 | if (dev_isalive(dev)) { |
| 415 | iw = get_wireless_stats(dev); | 416 | iw = get_wireless_stats(dev); |
| 416 | if (iw) | 417 | if (iw) |
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index a23b45f08ec9..2e692afdc55d 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
| @@ -250,8 +250,7 @@ struct pktgen_dev { | |||
| 250 | __u64 count; /* Default No packets to send */ | 250 | __u64 count; /* Default No packets to send */ |
| 251 | __u64 sofar; /* How many pkts we've sent so far */ | 251 | __u64 sofar; /* How many pkts we've sent so far */ |
| 252 | __u64 tx_bytes; /* How many bytes we've transmitted */ | 252 | __u64 tx_bytes; /* How many bytes we've transmitted */ |
| 253 | __u64 errors; /* Errors when trying to transmit, | 253 | __u64 errors; /* Errors when trying to transmit, */ |
| 254 | pkts will be re-sent */ | ||
| 255 | 254 | ||
| 256 | /* runtime counters relating to clone_skb */ | 255 | /* runtime counters relating to clone_skb */ |
| 257 | 256 | ||
| @@ -3465,6 +3464,12 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev) | |||
| 3465 | pkt_dev->seq_num++; | 3464 | pkt_dev->seq_num++; |
| 3466 | pkt_dev->tx_bytes += pkt_dev->last_pkt_size; | 3465 | pkt_dev->tx_bytes += pkt_dev->last_pkt_size; |
| 3467 | break; | 3466 | break; |
| 3467 | case NET_XMIT_DROP: | ||
| 3468 | case NET_XMIT_CN: | ||
| 3469 | case NET_XMIT_POLICED: | ||
| 3470 | /* skb has been consumed */ | ||
| 3471 | pkt_dev->errors++; | ||
| 3472 | break; | ||
| 3468 | default: /* Drivers are not supposed to return other values! */ | 3473 | default: /* Drivers are not supposed to return other values! */ |
| 3469 | if (net_ratelimit()) | 3474 | if (net_ratelimit()) |
| 3470 | pr_info("pktgen: %s xmit error: %d\n", | 3475 | pr_info("pktgen: %s xmit error: %d\n", |
| @@ -3519,6 +3524,7 @@ static int pktgen_thread_worker(void *arg) | |||
| 3519 | wait_event_interruptible_timeout(t->queue, | 3524 | wait_event_interruptible_timeout(t->queue, |
| 3520 | t->control != 0, | 3525 | t->control != 0, |
| 3521 | HZ/10); | 3526 | HZ/10); |
| 3527 | try_to_freeze(); | ||
| 3522 | continue; | 3528 | continue; |
| 3523 | } | 3529 | } |
| 3524 | 3530 | ||
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 33148a568199..4c7d3f635ba7 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
| @@ -89,6 +89,14 @@ int rtnl_is_locked(void) | |||
| 89 | } | 89 | } |
| 90 | EXPORT_SYMBOL(rtnl_is_locked); | 90 | EXPORT_SYMBOL(rtnl_is_locked); |
| 91 | 91 | ||
| 92 | #ifdef CONFIG_PROVE_LOCKING | ||
| 93 | int lockdep_rtnl_is_held(void) | ||
| 94 | { | ||
| 95 | return lockdep_is_held(&rtnl_mutex); | ||
| 96 | } | ||
| 97 | EXPORT_SYMBOL(lockdep_rtnl_is_held); | ||
| 98 | #endif /* #ifdef CONFIG_PROVE_LOCKING */ | ||
| 99 | |||
| 92 | static struct rtnl_link *rtnl_msg_handlers[NPROTO]; | 100 | static struct rtnl_link *rtnl_msg_handlers[NPROTO]; |
| 93 | 101 | ||
| 94 | static inline int rtm_msgindex(int msgtype) | 102 | static inline int rtm_msgindex(int msgtype) |
| @@ -1364,15 +1372,15 @@ static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi | |||
| 1364 | case NETDEV_UNREGISTER: | 1372 | case NETDEV_UNREGISTER: |
| 1365 | rtmsg_ifinfo(RTM_DELLINK, dev, ~0U); | 1373 | rtmsg_ifinfo(RTM_DELLINK, dev, ~0U); |
| 1366 | break; | 1374 | break; |
| 1367 | case NETDEV_REGISTER: | ||
| 1368 | rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U); | ||
| 1369 | break; | ||
| 1370 | case NETDEV_UP: | 1375 | case NETDEV_UP: |
| 1371 | case NETDEV_DOWN: | 1376 | case NETDEV_DOWN: |
| 1372 | rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING); | 1377 | rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING); |
| 1373 | break; | 1378 | break; |
| 1379 | case NETDEV_POST_INIT: | ||
| 1380 | case NETDEV_REGISTER: | ||
| 1374 | case NETDEV_CHANGE: | 1381 | case NETDEV_CHANGE: |
| 1375 | case NETDEV_GOING_DOWN: | 1382 | case NETDEV_GOING_DOWN: |
| 1383 | case NETDEV_UNREGISTER_BATCH: | ||
| 1376 | break; | 1384 | break; |
| 1377 | default: | 1385 | default: |
| 1378 | rtmsg_ifinfo(RTM_NEWLINK, dev, 0); | 1386 | rtmsg_ifinfo(RTM_NEWLINK, dev, 0); |
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index bfa3e7865a8c..93c4e060c91e 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
| @@ -93,7 +93,7 @@ static int sock_pipe_buf_steal(struct pipe_inode_info *pipe, | |||
| 93 | 93 | ||
| 94 | 94 | ||
| 95 | /* Pipe buffer operations for a socket. */ | 95 | /* Pipe buffer operations for a socket. */ |
| 96 | static struct pipe_buf_operations sock_pipe_buf_ops = { | 96 | static const struct pipe_buf_operations sock_pipe_buf_ops = { |
| 97 | .can_merge = 0, | 97 | .can_merge = 0, |
| 98 | .map = generic_pipe_buf_map, | 98 | .map = generic_pipe_buf_map, |
| 99 | .unmap = generic_pipe_buf_unmap, | 99 | .unmap = generic_pipe_buf_unmap, |
diff --git a/net/core/sock.c b/net/core/sock.c index 76ff58d43e26..305cba401ae6 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
| @@ -1073,7 +1073,8 @@ static void __sk_free(struct sock *sk) | |||
| 1073 | if (sk->sk_destruct) | 1073 | if (sk->sk_destruct) |
| 1074 | sk->sk_destruct(sk); | 1074 | sk->sk_destruct(sk); |
| 1075 | 1075 | ||
| 1076 | filter = rcu_dereference(sk->sk_filter); | 1076 | filter = rcu_dereference_check(sk->sk_filter, |
| 1077 | atomic_read(&sk->sk_wmem_alloc) == 0); | ||
| 1077 | if (filter) { | 1078 | if (filter) { |
| 1078 | sk_filter_uncharge(sk, filter); | 1079 | sk_filter_uncharge(sk, filter); |
| 1079 | rcu_assign_pointer(sk->sk_filter, NULL); | 1080 | rcu_assign_pointer(sk->sk_filter, NULL); |
| @@ -1205,6 +1206,10 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority) | |||
| 1205 | 1206 | ||
| 1206 | if (newsk->sk_prot->sockets_allocated) | 1207 | if (newsk->sk_prot->sockets_allocated) |
| 1207 | percpu_counter_inc(newsk->sk_prot->sockets_allocated); | 1208 | percpu_counter_inc(newsk->sk_prot->sockets_allocated); |
| 1209 | |||
| 1210 | if (sock_flag(newsk, SOCK_TIMESTAMP) || | ||
| 1211 | sock_flag(newsk, SOCK_TIMESTAMPING_RX_SOFTWARE)) | ||
| 1212 | net_enable_timestamp(); | ||
| 1208 | } | 1213 | } |
| 1209 | out: | 1214 | out: |
| 1210 | return newsk; | 1215 | return newsk; |
diff --git a/net/dccp/ccid.c b/net/dccp/ccid.c index f3e9ba1cfd01..ff16e9df1969 100644 --- a/net/dccp/ccid.c +++ b/net/dccp/ccid.c | |||
| @@ -77,34 +77,24 @@ int ccid_getsockopt_builtin_ccids(struct sock *sk, int len, | |||
| 77 | return err; | 77 | return err; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | static struct kmem_cache *ccid_kmem_cache_create(int obj_size, const char *fmt,...) | 80 | static struct kmem_cache *ccid_kmem_cache_create(int obj_size, char *slab_name_fmt, const char *fmt,...) |
| 81 | { | 81 | { |
| 82 | struct kmem_cache *slab; | 82 | struct kmem_cache *slab; |
| 83 | char slab_name_fmt[32], *slab_name; | ||
| 84 | va_list args; | 83 | va_list args; |
| 85 | 84 | ||
| 86 | va_start(args, fmt); | 85 | va_start(args, fmt); |
| 87 | vsnprintf(slab_name_fmt, sizeof(slab_name_fmt), fmt, args); | 86 | vsnprintf(slab_name_fmt, CCID_SLAB_NAME_LENGTH, fmt, args); |
| 88 | va_end(args); | 87 | va_end(args); |
| 89 | 88 | ||
| 90 | slab_name = kstrdup(slab_name_fmt, GFP_KERNEL); | 89 | slab = kmem_cache_create(slab_name_fmt, sizeof(struct ccid) + obj_size, 0, |
| 91 | if (slab_name == NULL) | ||
| 92 | return NULL; | ||
| 93 | slab = kmem_cache_create(slab_name, sizeof(struct ccid) + obj_size, 0, | ||
| 94 | SLAB_HWCACHE_ALIGN, NULL); | 90 | SLAB_HWCACHE_ALIGN, NULL); |
| 95 | if (slab == NULL) | ||
| 96 | kfree(slab_name); | ||
| 97 | return slab; | 91 | return slab; |
| 98 | } | 92 | } |
| 99 | 93 | ||
| 100 | static void ccid_kmem_cache_destroy(struct kmem_cache *slab) | 94 | static void ccid_kmem_cache_destroy(struct kmem_cache *slab) |
| 101 | { | 95 | { |
| 102 | if (slab != NULL) { | 96 | if (slab != NULL) |
| 103 | const char *name = kmem_cache_name(slab); | ||
| 104 | |||
| 105 | kmem_cache_destroy(slab); | 97 | kmem_cache_destroy(slab); |
| 106 | kfree(name); | ||
| 107 | } | ||
| 108 | } | 98 | } |
| 109 | 99 | ||
| 110 | static int ccid_activate(struct ccid_operations *ccid_ops) | 100 | static int ccid_activate(struct ccid_operations *ccid_ops) |
| @@ -113,6 +103,7 @@ static int ccid_activate(struct ccid_operations *ccid_ops) | |||
| 113 | 103 | ||
| 114 | ccid_ops->ccid_hc_rx_slab = | 104 | ccid_ops->ccid_hc_rx_slab = |
| 115 | ccid_kmem_cache_create(ccid_ops->ccid_hc_rx_obj_size, | 105 | ccid_kmem_cache_create(ccid_ops->ccid_hc_rx_obj_size, |
| 106 | ccid_ops->ccid_hc_rx_slab_name, | ||
| 116 | "ccid%u_hc_rx_sock", | 107 | "ccid%u_hc_rx_sock", |
| 117 | ccid_ops->ccid_id); | 108 | ccid_ops->ccid_id); |
| 118 | if (ccid_ops->ccid_hc_rx_slab == NULL) | 109 | if (ccid_ops->ccid_hc_rx_slab == NULL) |
| @@ -120,6 +111,7 @@ static int ccid_activate(struct ccid_operations *ccid_ops) | |||
| 120 | 111 | ||
| 121 | ccid_ops->ccid_hc_tx_slab = | 112 | ccid_ops->ccid_hc_tx_slab = |
| 122 | ccid_kmem_cache_create(ccid_ops->ccid_hc_tx_obj_size, | 113 | ccid_kmem_cache_create(ccid_ops->ccid_hc_tx_obj_size, |
| 114 | ccid_ops->ccid_hc_tx_slab_name, | ||
| 123 | "ccid%u_hc_tx_sock", | 115 | "ccid%u_hc_tx_sock", |
| 124 | ccid_ops->ccid_id); | 116 | ccid_ops->ccid_id); |
| 125 | if (ccid_ops->ccid_hc_tx_slab == NULL) | 117 | if (ccid_ops->ccid_hc_tx_slab == NULL) |
diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h index facedd20b531..6df6f8ac9636 100644 --- a/net/dccp/ccid.h +++ b/net/dccp/ccid.h | |||
| @@ -19,7 +19,9 @@ | |||
| 19 | #include <linux/list.h> | 19 | #include <linux/list.h> |
| 20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
| 21 | 21 | ||
| 22 | #define CCID_MAX 255 | 22 | /* maximum value for a CCID (RFC 4340, 19.5) */ |
| 23 | #define CCID_MAX 255 | ||
| 24 | #define CCID_SLAB_NAME_LENGTH 32 | ||
| 23 | 25 | ||
| 24 | struct tcp_info; | 26 | struct tcp_info; |
| 25 | 27 | ||
| @@ -49,6 +51,8 @@ struct ccid_operations { | |||
| 49 | const char *ccid_name; | 51 | const char *ccid_name; |
| 50 | struct kmem_cache *ccid_hc_rx_slab, | 52 | struct kmem_cache *ccid_hc_rx_slab, |
| 51 | *ccid_hc_tx_slab; | 53 | *ccid_hc_tx_slab; |
| 54 | char ccid_hc_rx_slab_name[CCID_SLAB_NAME_LENGTH]; | ||
| 55 | char ccid_hc_tx_slab_name[CCID_SLAB_NAME_LENGTH]; | ||
| 52 | __u32 ccid_hc_rx_obj_size, | 56 | __u32 ccid_hc_rx_obj_size, |
| 53 | ccid_hc_tx_obj_size; | 57 | ccid_hc_tx_obj_size; |
| 54 | /* Interface Routines */ | 58 | /* Interface Routines */ |
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index efbcfdc12796..dad7bc4878e0 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
| @@ -408,7 +408,7 @@ struct sock *dccp_v4_request_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
| 408 | 408 | ||
| 409 | dccp_sync_mss(newsk, dst_mtu(dst)); | 409 | dccp_sync_mss(newsk, dst_mtu(dst)); |
| 410 | 410 | ||
| 411 | __inet_hash_nolisten(newsk); | 411 | __inet_hash_nolisten(newsk, NULL); |
| 412 | __inet_inherit_port(sk, newsk); | 412 | __inet_inherit_port(sk, newsk); |
| 413 | 413 | ||
| 414 | return newsk; | 414 | return newsk; |
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 6574215a1f51..baf05cf43c28 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
| @@ -46,7 +46,7 @@ static void dccp_v6_hash(struct sock *sk) | |||
| 46 | return; | 46 | return; |
| 47 | } | 47 | } |
| 48 | local_bh_disable(); | 48 | local_bh_disable(); |
| 49 | __inet6_hash(sk); | 49 | __inet6_hash(sk, NULL); |
| 50 | local_bh_enable(); | 50 | local_bh_enable(); |
| 51 | } | 51 | } |
| 52 | } | 52 | } |
| @@ -644,7 +644,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, | |||
| 644 | newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6; | 644 | newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6; |
| 645 | newinet->inet_rcv_saddr = LOOPBACK4_IPV6; | 645 | newinet->inet_rcv_saddr = LOOPBACK4_IPV6; |
| 646 | 646 | ||
| 647 | __inet6_hash(newsk); | 647 | __inet6_hash(newsk, NULL); |
| 648 | __inet_inherit_port(sk, newsk); | 648 | __inet_inherit_port(sk, newsk); |
| 649 | 649 | ||
| 650 | return newsk; | 650 | return newsk; |
diff --git a/net/dccp/probe.c b/net/dccp/probe.c index dc328425fa20..f5b3464f1242 100644 --- a/net/dccp/probe.c +++ b/net/dccp/probe.c | |||
| @@ -43,7 +43,7 @@ static int bufsize = 64 * 1024; | |||
| 43 | static const char procname[] = "dccpprobe"; | 43 | static const char procname[] = "dccpprobe"; |
| 44 | 44 | ||
| 45 | static struct { | 45 | static struct { |
| 46 | struct kfifo *fifo; | 46 | struct kfifo fifo; |
| 47 | spinlock_t lock; | 47 | spinlock_t lock; |
| 48 | wait_queue_head_t wait; | 48 | wait_queue_head_t wait; |
| 49 | struct timespec tstart; | 49 | struct timespec tstart; |
| @@ -67,7 +67,7 @@ static void printl(const char *fmt, ...) | |||
| 67 | len += vscnprintf(tbuf+len, sizeof(tbuf)-len, fmt, args); | 67 | len += vscnprintf(tbuf+len, sizeof(tbuf)-len, fmt, args); |
| 68 | va_end(args); | 68 | va_end(args); |
| 69 | 69 | ||
| 70 | kfifo_put(dccpw.fifo, tbuf, len); | 70 | kfifo_in_locked(&dccpw.fifo, tbuf, len, &dccpw.lock); |
| 71 | wake_up(&dccpw.wait); | 71 | wake_up(&dccpw.wait); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| @@ -109,7 +109,7 @@ static struct jprobe dccp_send_probe = { | |||
| 109 | 109 | ||
| 110 | static int dccpprobe_open(struct inode *inode, struct file *file) | 110 | static int dccpprobe_open(struct inode *inode, struct file *file) |
| 111 | { | 111 | { |
| 112 | kfifo_reset(dccpw.fifo); | 112 | kfifo_reset(&dccpw.fifo); |
| 113 | getnstimeofday(&dccpw.tstart); | 113 | getnstimeofday(&dccpw.tstart); |
| 114 | return 0; | 114 | return 0; |
| 115 | } | 115 | } |
| @@ -131,11 +131,11 @@ static ssize_t dccpprobe_read(struct file *file, char __user *buf, | |||
| 131 | return -ENOMEM; | 131 | return -ENOMEM; |
| 132 | 132 | ||
| 133 | error = wait_event_interruptible(dccpw.wait, | 133 | error = wait_event_interruptible(dccpw.wait, |
| 134 | __kfifo_len(dccpw.fifo) != 0); | 134 | kfifo_len(&dccpw.fifo) != 0); |
| 135 | if (error) | 135 | if (error) |
| 136 | goto out_free; | 136 | goto out_free; |
| 137 | 137 | ||
| 138 | cnt = kfifo_get(dccpw.fifo, tbuf, len); | 138 | cnt = kfifo_out_locked(&dccpw.fifo, tbuf, len, &dccpw.lock); |
| 139 | error = copy_to_user(buf, tbuf, cnt) ? -EFAULT : 0; | 139 | error = copy_to_user(buf, tbuf, cnt) ? -EFAULT : 0; |
| 140 | 140 | ||
| 141 | out_free: | 141 | out_free: |
| @@ -156,14 +156,13 @@ static __init int dccpprobe_init(void) | |||
| 156 | 156 | ||
| 157 | init_waitqueue_head(&dccpw.wait); | 157 | init_waitqueue_head(&dccpw.wait); |
| 158 | spin_lock_init(&dccpw.lock); | 158 | spin_lock_init(&dccpw.lock); |
| 159 | dccpw.fifo = kfifo_alloc(bufsize, GFP_KERNEL, &dccpw.lock); | 159 | if (kfifo_alloc(&dccpw.fifo, bufsize, GFP_KERNEL)) |
| 160 | if (IS_ERR(dccpw.fifo)) | 160 | return ret; |
| 161 | return PTR_ERR(dccpw.fifo); | ||
| 162 | |||
| 163 | if (!proc_net_fops_create(&init_net, procname, S_IRUSR, &dccpprobe_fops)) | 161 | if (!proc_net_fops_create(&init_net, procname, S_IRUSR, &dccpprobe_fops)) |
| 164 | goto err0; | 162 | goto err0; |
| 165 | 163 | ||
| 166 | ret = register_jprobe(&dccp_send_probe); | 164 | try_then_request_module((ret = register_jprobe(&dccp_send_probe)) == 0, |
| 165 | "dccp"); | ||
| 167 | if (ret) | 166 | if (ret) |
| 168 | goto err1; | 167 | goto err1; |
| 169 | 168 | ||
| @@ -172,14 +171,14 @@ static __init int dccpprobe_init(void) | |||
| 172 | err1: | 171 | err1: |
| 173 | proc_net_remove(&init_net, procname); | 172 | proc_net_remove(&init_net, procname); |
| 174 | err0: | 173 | err0: |
| 175 | kfifo_free(dccpw.fifo); | 174 | kfifo_free(&dccpw.fifo); |
| 176 | return ret; | 175 | return ret; |
| 177 | } | 176 | } |
| 178 | module_init(dccpprobe_init); | 177 | module_init(dccpprobe_init); |
| 179 | 178 | ||
| 180 | static __exit void dccpprobe_exit(void) | 179 | static __exit void dccpprobe_exit(void) |
| 181 | { | 180 | { |
| 182 | kfifo_free(dccpw.fifo); | 181 | kfifo_free(&dccpw.fifo); |
| 183 | proc_net_remove(&init_net, procname); | 182 | proc_net_remove(&init_net, procname); |
| 184 | unregister_jprobe(&dccp_send_probe); | 183 | unregister_jprobe(&dccp_send_probe); |
| 185 | 184 | ||
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index a03284061a31..a7bf03ca0a36 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c | |||
| @@ -1155,8 +1155,8 @@ static int __dn_route_output_key(struct dst_entry **pprt, const struct flowi *fl | |||
| 1155 | 1155 | ||
| 1156 | if (!(flags & MSG_TRYHARD)) { | 1156 | if (!(flags & MSG_TRYHARD)) { |
| 1157 | rcu_read_lock_bh(); | 1157 | rcu_read_lock_bh(); |
| 1158 | for(rt = rcu_dereference(dn_rt_hash_table[hash].chain); rt; | 1158 | for (rt = rcu_dereference_bh(dn_rt_hash_table[hash].chain); rt; |
| 1159 | rt = rcu_dereference(rt->u.dst.dn_next)) { | 1159 | rt = rcu_dereference_bh(rt->u.dst.dn_next)) { |
| 1160 | if ((flp->fld_dst == rt->fl.fld_dst) && | 1160 | if ((flp->fld_dst == rt->fl.fld_dst) && |
| 1161 | (flp->fld_src == rt->fl.fld_src) && | 1161 | (flp->fld_src == rt->fl.fld_src) && |
| 1162 | (flp->mark == rt->fl.mark) && | 1162 | (flp->mark == rt->fl.mark) && |
| @@ -1618,9 +1618,9 @@ int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 1618 | if (h > s_h) | 1618 | if (h > s_h) |
| 1619 | s_idx = 0; | 1619 | s_idx = 0; |
| 1620 | rcu_read_lock_bh(); | 1620 | rcu_read_lock_bh(); |
| 1621 | for(rt = rcu_dereference(dn_rt_hash_table[h].chain), idx = 0; | 1621 | for(rt = rcu_dereference_bh(dn_rt_hash_table[h].chain), idx = 0; |
| 1622 | rt; | 1622 | rt; |
| 1623 | rt = rcu_dereference(rt->u.dst.dn_next), idx++) { | 1623 | rt = rcu_dereference_bh(rt->u.dst.dn_next), idx++) { |
| 1624 | if (idx < s_idx) | 1624 | if (idx < s_idx) |
| 1625 | continue; | 1625 | continue; |
| 1626 | skb_dst_set(skb, dst_clone(&rt->u.dst)); | 1626 | skb_dst_set(skb, dst_clone(&rt->u.dst)); |
| @@ -1654,12 +1654,12 @@ static struct dn_route *dn_rt_cache_get_first(struct seq_file *seq) | |||
| 1654 | 1654 | ||
| 1655 | for(s->bucket = dn_rt_hash_mask; s->bucket >= 0; --s->bucket) { | 1655 | for(s->bucket = dn_rt_hash_mask; s->bucket >= 0; --s->bucket) { |
| 1656 | rcu_read_lock_bh(); | 1656 | rcu_read_lock_bh(); |
| 1657 | rt = dn_rt_hash_table[s->bucket].chain; | 1657 | rt = rcu_dereference_bh(dn_rt_hash_table[s->bucket].chain); |
| 1658 | if (rt) | 1658 | if (rt) |
| 1659 | break; | 1659 | break; |
| 1660 | rcu_read_unlock_bh(); | 1660 | rcu_read_unlock_bh(); |
| 1661 | } | 1661 | } |
| 1662 | return rcu_dereference(rt); | 1662 | return rt; |
| 1663 | } | 1663 | } |
| 1664 | 1664 | ||
| 1665 | static struct dn_route *dn_rt_cache_get_next(struct seq_file *seq, struct dn_route *rt) | 1665 | static struct dn_route *dn_rt_cache_get_next(struct seq_file *seq, struct dn_route *rt) |
| @@ -1674,7 +1674,7 @@ static struct dn_route *dn_rt_cache_get_next(struct seq_file *seq, struct dn_rou | |||
| 1674 | rcu_read_lock_bh(); | 1674 | rcu_read_lock_bh(); |
| 1675 | rt = dn_rt_hash_table[s->bucket].chain; | 1675 | rt = dn_rt_hash_table[s->bucket].chain; |
| 1676 | } | 1676 | } |
| 1677 | return rcu_dereference(rt); | 1677 | return rcu_dereference_bh(rt); |
| 1678 | } | 1678 | } |
| 1679 | 1679 | ||
| 1680 | static void *dn_rt_cache_seq_start(struct seq_file *seq, loff_t *pos) | 1680 | static void *dn_rt_cache_seq_start(struct seq_file *seq, loff_t *pos) |
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig index 70491d9035eb..0c94a1ac2946 100644 --- a/net/ipv4/Kconfig +++ b/net/ipv4/Kconfig | |||
| @@ -166,7 +166,7 @@ config IP_PNP_DHCP | |||
| 166 | 166 | ||
| 167 | If unsure, say Y. Note that if you want to use DHCP, a DHCP server | 167 | If unsure, say Y. Note that if you want to use DHCP, a DHCP server |
| 168 | must be operating on your network. Read | 168 | must be operating on your network. Read |
| 169 | <file:Documentation/filesystems/nfsroot.txt> for details. | 169 | <file:Documentation/filesystems/nfs/nfsroot.txt> for details. |
| 170 | 170 | ||
| 171 | config IP_PNP_BOOTP | 171 | config IP_PNP_BOOTP |
| 172 | bool "IP: BOOTP support" | 172 | bool "IP: BOOTP support" |
| @@ -181,7 +181,7 @@ config IP_PNP_BOOTP | |||
| 181 | does BOOTP itself, providing all necessary information on the kernel | 181 | does BOOTP itself, providing all necessary information on the kernel |
| 182 | command line, you can say N here. If unsure, say Y. Note that if you | 182 | command line, you can say N here. If unsure, say Y. Note that if you |
| 183 | want to use BOOTP, a BOOTP server must be operating on your network. | 183 | want to use BOOTP, a BOOTP server must be operating on your network. |
| 184 | Read <file:Documentation/filesystems/nfsroot.txt> for details. | 184 | Read <file:Documentation/filesystems/nfs/nfsroot.txt> for details. |
| 185 | 185 | ||
| 186 | config IP_PNP_RARP | 186 | config IP_PNP_RARP |
| 187 | bool "IP: RARP support" | 187 | bool "IP: RARP support" |
| @@ -194,7 +194,7 @@ config IP_PNP_RARP | |||
| 194 | older protocol which is being obsoleted by BOOTP and DHCP), say Y | 194 | older protocol which is being obsoleted by BOOTP and DHCP), say Y |
| 195 | here. Note that if you want to use RARP, a RARP server must be | 195 | here. Note that if you want to use RARP, a RARP server must be |
| 196 | operating on your network. Read | 196 | operating on your network. Read |
| 197 | <file:Documentation/filesystems/nfsroot.txt> for details. | 197 | <file:Documentation/filesystems/nfs/nfsroot.txt> for details. |
| 198 | 198 | ||
| 199 | # not yet ready.. | 199 | # not yet ready.. |
| 200 | # bool ' IP: ARP support' CONFIG_IP_PNP_ARP | 200 | # bool ' IP: ARP support' CONFIG_IP_PNP_ARP |
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 5cdbc102a418..26dec2be9615 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
| @@ -1317,14 +1317,19 @@ static int devinet_sysctl_forward(ctl_table *ctl, int write, | |||
| 1317 | { | 1317 | { |
| 1318 | int *valp = ctl->data; | 1318 | int *valp = ctl->data; |
| 1319 | int val = *valp; | 1319 | int val = *valp; |
| 1320 | loff_t pos = *ppos; | ||
| 1320 | int ret = proc_dointvec(ctl, write, buffer, lenp, ppos); | 1321 | int ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 1321 | 1322 | ||
| 1322 | if (write && *valp != val) { | 1323 | if (write && *valp != val) { |
| 1323 | struct net *net = ctl->extra2; | 1324 | struct net *net = ctl->extra2; |
| 1324 | 1325 | ||
| 1325 | if (valp != &IPV4_DEVCONF_DFLT(net, FORWARDING)) { | 1326 | if (valp != &IPV4_DEVCONF_DFLT(net, FORWARDING)) { |
| 1326 | if (!rtnl_trylock()) | 1327 | if (!rtnl_trylock()) { |
| 1328 | /* Restore the original values before restarting */ | ||
| 1329 | *valp = val; | ||
| 1330 | *ppos = pos; | ||
| 1327 | return restart_syscall(); | 1331 | return restart_syscall(); |
| 1332 | } | ||
| 1328 | if (valp == &IPV4_DEVCONF_ALL(net, FORWARDING)) { | 1333 | if (valp == &IPV4_DEVCONF_ALL(net, FORWARDING)) { |
| 1329 | inet_forward_change(net); | 1334 | inet_forward_change(net); |
| 1330 | } else if (*valp) { | 1335 | } else if (*valp) { |
| @@ -1397,6 +1402,7 @@ static struct devinet_sysctl_table { | |||
| 1397 | DEVINET_SYSCTL_RW_ENTRY(ACCEPT_SOURCE_ROUTE, | 1402 | DEVINET_SYSCTL_RW_ENTRY(ACCEPT_SOURCE_ROUTE, |
| 1398 | "accept_source_route"), | 1403 | "accept_source_route"), |
| 1399 | DEVINET_SYSCTL_RW_ENTRY(ACCEPT_LOCAL, "accept_local"), | 1404 | DEVINET_SYSCTL_RW_ENTRY(ACCEPT_LOCAL, "accept_local"), |
| 1405 | DEVINET_SYSCTL_RW_ENTRY(SRC_VMARK, "src_valid_mark"), | ||
| 1400 | DEVINET_SYSCTL_RW_ENTRY(PROXY_ARP, "proxy_arp"), | 1406 | DEVINET_SYSCTL_RW_ENTRY(PROXY_ARP, "proxy_arp"), |
| 1401 | DEVINET_SYSCTL_RW_ENTRY(MEDIUM_ID, "medium_id"), | 1407 | DEVINET_SYSCTL_RW_ENTRY(MEDIUM_ID, "medium_id"), |
| 1402 | DEVINET_SYSCTL_RW_ENTRY(BOOTP_RELAY, "bootp_relay"), | 1408 | DEVINET_SYSCTL_RW_ENTRY(BOOTP_RELAY, "bootp_relay"), |
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 3323168ee52d..82dbf711d6d0 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
| @@ -252,6 +252,8 @@ int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif, | |||
| 252 | no_addr = in_dev->ifa_list == NULL; | 252 | no_addr = in_dev->ifa_list == NULL; |
| 253 | rpf = IN_DEV_RPFILTER(in_dev); | 253 | rpf = IN_DEV_RPFILTER(in_dev); |
| 254 | accept_local = IN_DEV_ACCEPT_LOCAL(in_dev); | 254 | accept_local = IN_DEV_ACCEPT_LOCAL(in_dev); |
| 255 | if (mark && !IN_DEV_SRC_VMARK(in_dev)) | ||
| 256 | fl.mark = 0; | ||
| 255 | } | 257 | } |
| 256 | rcu_read_unlock(); | 258 | rcu_read_unlock(); |
| 257 | 259 | ||
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 76c08402c933..a42f658e756a 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
| @@ -946,7 +946,6 @@ int igmp_rcv(struct sk_buff *skb) | |||
| 946 | break; | 946 | break; |
| 947 | case IGMP_HOST_MEMBERSHIP_REPORT: | 947 | case IGMP_HOST_MEMBERSHIP_REPORT: |
| 948 | case IGMPV2_HOST_MEMBERSHIP_REPORT: | 948 | case IGMPV2_HOST_MEMBERSHIP_REPORT: |
| 949 | case IGMPV3_HOST_MEMBERSHIP_REPORT: | ||
| 950 | /* Is it our report looped back? */ | 949 | /* Is it our report looped back? */ |
| 951 | if (skb_rtable(skb)->fl.iif == 0) | 950 | if (skb_rtable(skb)->fl.iif == 0) |
| 952 | break; | 951 | break; |
| @@ -960,6 +959,7 @@ int igmp_rcv(struct sk_buff *skb) | |||
| 960 | in_dev_put(in_dev); | 959 | in_dev_put(in_dev); |
| 961 | return pim_rcv_v1(skb); | 960 | return pim_rcv_v1(skb); |
| 962 | #endif | 961 | #endif |
| 962 | case IGMPV3_HOST_MEMBERSHIP_REPORT: | ||
| 963 | case IGMP_DVMRP: | 963 | case IGMP_DVMRP: |
| 964 | case IGMP_TRACE: | 964 | case IGMP_TRACE: |
| 965 | case IGMP_HOST_LEAVE_MESSAGE: | 965 | case IGMP_HOST_LEAVE_MESSAGE: |
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index bdb78dd180ce..1aaa8110d84b 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c | |||
| @@ -368,7 +368,7 @@ static int inet_diag_bc_run(const void *bc, int len, | |||
| 368 | yes = entry->sport >= op[1].no; | 368 | yes = entry->sport >= op[1].no; |
| 369 | break; | 369 | break; |
| 370 | case INET_DIAG_BC_S_LE: | 370 | case INET_DIAG_BC_S_LE: |
| 371 | yes = entry->dport <= op[1].no; | 371 | yes = entry->sport <= op[1].no; |
| 372 | break; | 372 | break; |
| 373 | case INET_DIAG_BC_D_GE: | 373 | case INET_DIAG_BC_D_GE: |
| 374 | yes = entry->dport >= op[1].no; | 374 | yes = entry->dport >= op[1].no; |
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index 21e5e32d8c60..2b79377b468d 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c | |||
| @@ -351,12 +351,13 @@ static inline u32 inet_sk_port_offset(const struct sock *sk) | |||
| 351 | inet->inet_dport); | 351 | inet->inet_dport); |
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | void __inet_hash_nolisten(struct sock *sk) | 354 | int __inet_hash_nolisten(struct sock *sk, struct inet_timewait_sock *tw) |
| 355 | { | 355 | { |
| 356 | struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; | 356 | struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; |
| 357 | struct hlist_nulls_head *list; | 357 | struct hlist_nulls_head *list; |
| 358 | spinlock_t *lock; | 358 | spinlock_t *lock; |
| 359 | struct inet_ehash_bucket *head; | 359 | struct inet_ehash_bucket *head; |
| 360 | int twrefcnt = 0; | ||
| 360 | 361 | ||
| 361 | WARN_ON(!sk_unhashed(sk)); | 362 | WARN_ON(!sk_unhashed(sk)); |
| 362 | 363 | ||
| @@ -367,8 +368,13 @@ void __inet_hash_nolisten(struct sock *sk) | |||
| 367 | 368 | ||
| 368 | spin_lock(lock); | 369 | spin_lock(lock); |
| 369 | __sk_nulls_add_node_rcu(sk, list); | 370 | __sk_nulls_add_node_rcu(sk, list); |
| 371 | if (tw) { | ||
| 372 | WARN_ON(sk->sk_hash != tw->tw_hash); | ||
| 373 | twrefcnt = inet_twsk_unhash(tw); | ||
| 374 | } | ||
| 370 | spin_unlock(lock); | 375 | spin_unlock(lock); |
| 371 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); | 376 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); |
| 377 | return twrefcnt; | ||
| 372 | } | 378 | } |
| 373 | EXPORT_SYMBOL_GPL(__inet_hash_nolisten); | 379 | EXPORT_SYMBOL_GPL(__inet_hash_nolisten); |
| 374 | 380 | ||
| @@ -378,7 +384,7 @@ static void __inet_hash(struct sock *sk) | |||
| 378 | struct inet_listen_hashbucket *ilb; | 384 | struct inet_listen_hashbucket *ilb; |
| 379 | 385 | ||
| 380 | if (sk->sk_state != TCP_LISTEN) { | 386 | if (sk->sk_state != TCP_LISTEN) { |
| 381 | __inet_hash_nolisten(sk); | 387 | __inet_hash_nolisten(sk, NULL); |
| 382 | return; | 388 | return; |
| 383 | } | 389 | } |
| 384 | 390 | ||
| @@ -427,7 +433,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row, | |||
| 427 | struct sock *sk, u32 port_offset, | 433 | struct sock *sk, u32 port_offset, |
| 428 | int (*check_established)(struct inet_timewait_death_row *, | 434 | int (*check_established)(struct inet_timewait_death_row *, |
| 429 | struct sock *, __u16, struct inet_timewait_sock **), | 435 | struct sock *, __u16, struct inet_timewait_sock **), |
| 430 | void (*hash)(struct sock *sk)) | 436 | int (*hash)(struct sock *sk, struct inet_timewait_sock *twp)) |
| 431 | { | 437 | { |
| 432 | struct inet_hashinfo *hinfo = death_row->hashinfo; | 438 | struct inet_hashinfo *hinfo = death_row->hashinfo; |
| 433 | const unsigned short snum = inet_sk(sk)->inet_num; | 439 | const unsigned short snum = inet_sk(sk)->inet_num; |
| @@ -435,6 +441,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row, | |||
| 435 | struct inet_bind_bucket *tb; | 441 | struct inet_bind_bucket *tb; |
| 436 | int ret; | 442 | int ret; |
| 437 | struct net *net = sock_net(sk); | 443 | struct net *net = sock_net(sk); |
| 444 | int twrefcnt = 1; | ||
| 438 | 445 | ||
| 439 | if (!snum) { | 446 | if (!snum) { |
| 440 | int i, remaining, low, high, port; | 447 | int i, remaining, low, high, port; |
| @@ -493,13 +500,18 @@ ok: | |||
| 493 | inet_bind_hash(sk, tb, port); | 500 | inet_bind_hash(sk, tb, port); |
| 494 | if (sk_unhashed(sk)) { | 501 | if (sk_unhashed(sk)) { |
| 495 | inet_sk(sk)->inet_sport = htons(port); | 502 | inet_sk(sk)->inet_sport = htons(port); |
| 496 | hash(sk); | 503 | twrefcnt += hash(sk, tw); |
| 497 | } | 504 | } |
| 505 | if (tw) | ||
| 506 | twrefcnt += inet_twsk_bind_unhash(tw, hinfo); | ||
| 498 | spin_unlock(&head->lock); | 507 | spin_unlock(&head->lock); |
| 499 | 508 | ||
| 500 | if (tw) { | 509 | if (tw) { |
| 501 | inet_twsk_deschedule(tw, death_row); | 510 | inet_twsk_deschedule(tw, death_row); |
| 502 | inet_twsk_put(tw); | 511 | while (twrefcnt) { |
| 512 | twrefcnt--; | ||
| 513 | inet_twsk_put(tw); | ||
| 514 | } | ||
| 503 | } | 515 | } |
| 504 | 516 | ||
| 505 | ret = 0; | 517 | ret = 0; |
| @@ -510,7 +522,7 @@ ok: | |||
| 510 | tb = inet_csk(sk)->icsk_bind_hash; | 522 | tb = inet_csk(sk)->icsk_bind_hash; |
| 511 | spin_lock_bh(&head->lock); | 523 | spin_lock_bh(&head->lock); |
| 512 | if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) { | 524 | if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) { |
| 513 | hash(sk); | 525 | hash(sk, NULL); |
| 514 | spin_unlock_bh(&head->lock); | 526 | spin_unlock_bh(&head->lock); |
| 515 | return 0; | 527 | return 0; |
| 516 | } else { | 528 | } else { |
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index 0fdf45e4c90c..cc94cc2d8b2d 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c | |||
| @@ -15,9 +15,13 @@ | |||
| 15 | #include <net/ip.h> | 15 | #include <net/ip.h> |
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | /* | 18 | /** |
| 19 | * unhash a timewait socket from established hash | 19 | * inet_twsk_unhash - unhash a timewait socket from established hash |
| 20 | * lock must be hold by caller | 20 | * @tw: timewait socket |
| 21 | * | ||
| 22 | * unhash a timewait socket from established hash, if hashed. | ||
| 23 | * ehash lock must be held by caller. | ||
| 24 | * Returns 1 if caller should call inet_twsk_put() after lock release. | ||
| 21 | */ | 25 | */ |
| 22 | int inet_twsk_unhash(struct inet_timewait_sock *tw) | 26 | int inet_twsk_unhash(struct inet_timewait_sock *tw) |
| 23 | { | 27 | { |
| @@ -26,6 +30,37 @@ int inet_twsk_unhash(struct inet_timewait_sock *tw) | |||
| 26 | 30 | ||
| 27 | hlist_nulls_del_rcu(&tw->tw_node); | 31 | hlist_nulls_del_rcu(&tw->tw_node); |
| 28 | sk_nulls_node_init(&tw->tw_node); | 32 | sk_nulls_node_init(&tw->tw_node); |
| 33 | /* | ||
| 34 | * We cannot call inet_twsk_put() ourself under lock, | ||
| 35 | * caller must call it for us. | ||
| 36 | */ | ||
| 37 | return 1; | ||
| 38 | } | ||
| 39 | |||
| 40 | /** | ||
| 41 | * inet_twsk_bind_unhash - unhash a timewait socket from bind hash | ||
| 42 | * @tw: timewait socket | ||
| 43 | * @hashinfo: hashinfo pointer | ||
| 44 | * | ||
| 45 | * unhash a timewait socket from bind hash, if hashed. | ||
| 46 | * bind hash lock must be held by caller. | ||
| 47 | * Returns 1 if caller should call inet_twsk_put() after lock release. | ||
| 48 | */ | ||
| 49 | int inet_twsk_bind_unhash(struct inet_timewait_sock *tw, | ||
| 50 | struct inet_hashinfo *hashinfo) | ||
| 51 | { | ||
| 52 | struct inet_bind_bucket *tb = tw->tw_tb; | ||
| 53 | |||
| 54 | if (!tb) | ||
| 55 | return 0; | ||
| 56 | |||
| 57 | __hlist_del(&tw->tw_bind_node); | ||
| 58 | tw->tw_tb = NULL; | ||
| 59 | inet_bind_bucket_destroy(hashinfo->bind_bucket_cachep, tb); | ||
| 60 | /* | ||
| 61 | * We cannot call inet_twsk_put() ourself under lock, | ||
| 62 | * caller must call it for us. | ||
| 63 | */ | ||
| 29 | return 1; | 64 | return 1; |
| 30 | } | 65 | } |
| 31 | 66 | ||
| @@ -34,7 +69,6 @@ static void __inet_twsk_kill(struct inet_timewait_sock *tw, | |||
| 34 | struct inet_hashinfo *hashinfo) | 69 | struct inet_hashinfo *hashinfo) |
| 35 | { | 70 | { |
| 36 | struct inet_bind_hashbucket *bhead; | 71 | struct inet_bind_hashbucket *bhead; |
| 37 | struct inet_bind_bucket *tb; | ||
| 38 | int refcnt; | 72 | int refcnt; |
| 39 | /* Unlink from established hashes. */ | 73 | /* Unlink from established hashes. */ |
| 40 | spinlock_t *lock = inet_ehash_lockp(hashinfo, tw->tw_hash); | 74 | spinlock_t *lock = inet_ehash_lockp(hashinfo, tw->tw_hash); |
| @@ -46,15 +80,11 @@ static void __inet_twsk_kill(struct inet_timewait_sock *tw, | |||
| 46 | /* Disassociate with bind bucket. */ | 80 | /* Disassociate with bind bucket. */ |
| 47 | bhead = &hashinfo->bhash[inet_bhashfn(twsk_net(tw), tw->tw_num, | 81 | bhead = &hashinfo->bhash[inet_bhashfn(twsk_net(tw), tw->tw_num, |
| 48 | hashinfo->bhash_size)]; | 82 | hashinfo->bhash_size)]; |
| 83 | |||
| 49 | spin_lock(&bhead->lock); | 84 | spin_lock(&bhead->lock); |
| 50 | tb = tw->tw_tb; | 85 | refcnt += inet_twsk_bind_unhash(tw, hashinfo); |
| 51 | if (tb) { | ||
| 52 | __hlist_del(&tw->tw_bind_node); | ||
| 53 | tw->tw_tb = NULL; | ||
| 54 | inet_bind_bucket_destroy(hashinfo->bind_bucket_cachep, tb); | ||
| 55 | refcnt++; | ||
| 56 | } | ||
| 57 | spin_unlock(&bhead->lock); | 86 | spin_unlock(&bhead->lock); |
| 87 | |||
| 58 | #ifdef SOCK_REFCNT_DEBUG | 88 | #ifdef SOCK_REFCNT_DEBUG |
| 59 | if (atomic_read(&tw->tw_refcnt) != 1) { | 89 | if (atomic_read(&tw->tw_refcnt) != 1) { |
| 60 | printk(KERN_DEBUG "%s timewait_sock %p refcnt=%d\n", | 90 | printk(KERN_DEBUG "%s timewait_sock %p refcnt=%d\n", |
| @@ -126,7 +156,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk, | |||
| 126 | 156 | ||
| 127 | /* | 157 | /* |
| 128 | * Notes : | 158 | * Notes : |
| 129 | * - We initially set tw_refcnt to 0 in inet_twsk_alloc() | 159 | * - We initially set tw_refcnt to 0 in inet_twsk_alloc() |
| 130 | * - We add one reference for the bhash link | 160 | * - We add one reference for the bhash link |
| 131 | * - We add one reference for the ehash link | 161 | * - We add one reference for the ehash link |
| 132 | * - We want this refcnt update done before allowing other | 162 | * - We want this refcnt update done before allowing other |
| @@ -136,7 +166,6 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk, | |||
| 136 | 166 | ||
| 137 | spin_unlock(lock); | 167 | spin_unlock(lock); |
| 138 | } | 168 | } |
| 139 | |||
| 140 | EXPORT_SYMBOL_GPL(__inet_twsk_hashdance); | 169 | EXPORT_SYMBOL_GPL(__inet_twsk_hashdance); |
| 141 | 170 | ||
| 142 | struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int state) | 171 | struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int state) |
| @@ -177,7 +206,6 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int stat | |||
| 177 | 206 | ||
| 178 | return tw; | 207 | return tw; |
| 179 | } | 208 | } |
| 180 | |||
| 181 | EXPORT_SYMBOL_GPL(inet_twsk_alloc); | 209 | EXPORT_SYMBOL_GPL(inet_twsk_alloc); |
| 182 | 210 | ||
| 183 | /* Returns non-zero if quota exceeded. */ | 211 | /* Returns non-zero if quota exceeded. */ |
| @@ -256,7 +284,6 @@ void inet_twdr_hangman(unsigned long data) | |||
| 256 | out: | 284 | out: |
| 257 | spin_unlock(&twdr->death_lock); | 285 | spin_unlock(&twdr->death_lock); |
| 258 | } | 286 | } |
| 259 | |||
| 260 | EXPORT_SYMBOL_GPL(inet_twdr_hangman); | 287 | EXPORT_SYMBOL_GPL(inet_twdr_hangman); |
| 261 | 288 | ||
| 262 | void inet_twdr_twkill_work(struct work_struct *work) | 289 | void inet_twdr_twkill_work(struct work_struct *work) |
| @@ -287,7 +314,6 @@ void inet_twdr_twkill_work(struct work_struct *work) | |||
| 287 | spin_unlock_bh(&twdr->death_lock); | 314 | spin_unlock_bh(&twdr->death_lock); |
| 288 | } | 315 | } |
| 289 | } | 316 | } |
| 290 | |||
| 291 | EXPORT_SYMBOL_GPL(inet_twdr_twkill_work); | 317 | EXPORT_SYMBOL_GPL(inet_twdr_twkill_work); |
| 292 | 318 | ||
| 293 | /* These are always called from BH context. See callers in | 319 | /* These are always called from BH context. See callers in |
| @@ -307,7 +333,6 @@ void inet_twsk_deschedule(struct inet_timewait_sock *tw, | |||
| 307 | spin_unlock(&twdr->death_lock); | 333 | spin_unlock(&twdr->death_lock); |
| 308 | __inet_twsk_kill(tw, twdr->hashinfo); | 334 | __inet_twsk_kill(tw, twdr->hashinfo); |
| 309 | } | 335 | } |
| 310 | |||
| 311 | EXPORT_SYMBOL(inet_twsk_deschedule); | 336 | EXPORT_SYMBOL(inet_twsk_deschedule); |
| 312 | 337 | ||
| 313 | void inet_twsk_schedule(struct inet_timewait_sock *tw, | 338 | void inet_twsk_schedule(struct inet_timewait_sock *tw, |
| @@ -388,7 +413,6 @@ void inet_twsk_schedule(struct inet_timewait_sock *tw, | |||
| 388 | mod_timer(&twdr->tw_timer, jiffies + twdr->period); | 413 | mod_timer(&twdr->tw_timer, jiffies + twdr->period); |
| 389 | spin_unlock(&twdr->death_lock); | 414 | spin_unlock(&twdr->death_lock); |
| 390 | } | 415 | } |
| 391 | |||
| 392 | EXPORT_SYMBOL_GPL(inet_twsk_schedule); | 416 | EXPORT_SYMBOL_GPL(inet_twsk_schedule); |
| 393 | 417 | ||
| 394 | void inet_twdr_twcal_tick(unsigned long data) | 418 | void inet_twdr_twcal_tick(unsigned long data) |
| @@ -449,7 +473,6 @@ out: | |||
| 449 | #endif | 473 | #endif |
| 450 | spin_unlock(&twdr->death_lock); | 474 | spin_unlock(&twdr->death_lock); |
| 451 | } | 475 | } |
| 452 | |||
| 453 | EXPORT_SYMBOL_GPL(inet_twdr_twcal_tick); | 476 | EXPORT_SYMBOL_GPL(inet_twdr_twcal_tick); |
| 454 | 477 | ||
| 455 | void inet_twsk_purge(struct inet_hashinfo *hashinfo, | 478 | void inet_twsk_purge(struct inet_hashinfo *hashinfo, |
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index e34013a78ef4..3451799e3dbf 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
| @@ -254,7 +254,7 @@ int ip_mc_output(struct sk_buff *skb) | |||
| 254 | */ | 254 | */ |
| 255 | 255 | ||
| 256 | if (rt->rt_flags&RTCF_MULTICAST) { | 256 | if (rt->rt_flags&RTCF_MULTICAST) { |
| 257 | if ((!sk || inet_sk(sk)->mc_loop) | 257 | if (sk_mc_loop(sk) |
| 258 | #ifdef CONFIG_IP_MROUTE | 258 | #ifdef CONFIG_IP_MROUTE |
| 259 | /* Small optimization: do not loopback not local frames, | 259 | /* Small optimization: do not loopback not local frames, |
| 260 | which returned after forwarding; they will be dropped | 260 | which returned after forwarding; they will be dropped |
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c index 38fbf04150ae..544ce0876f12 100644 --- a/net/ipv4/ipcomp.c +++ b/net/ipv4/ipcomp.c | |||
| @@ -124,16 +124,12 @@ static int ipcomp4_init_state(struct xfrm_state *x) | |||
| 124 | if (x->props.mode == XFRM_MODE_TUNNEL) { | 124 | if (x->props.mode == XFRM_MODE_TUNNEL) { |
| 125 | err = ipcomp_tunnel_attach(x); | 125 | err = ipcomp_tunnel_attach(x); |
| 126 | if (err) | 126 | if (err) |
| 127 | goto error_tunnel; | 127 | goto out; |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | err = 0; | 130 | err = 0; |
| 131 | out: | 131 | out: |
| 132 | return err; | 132 | return err; |
| 133 | |||
| 134 | error_tunnel: | ||
| 135 | ipcomp_destroy(x); | ||
| 136 | goto out; | ||
| 137 | } | 133 | } |
| 138 | 134 | ||
| 139 | static const struct xfrm_type ipcomp_type = { | 135 | static const struct xfrm_type ipcomp_type = { |
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 4e08b7f2331c..10a6a604bf32 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c | |||
| @@ -1446,7 +1446,7 @@ late_initcall(ip_auto_config); | |||
| 1446 | 1446 | ||
| 1447 | /* | 1447 | /* |
| 1448 | * Decode any IP configuration options in the "ip=" or "nfsaddrs=" kernel | 1448 | * Decode any IP configuration options in the "ip=" or "nfsaddrs=" kernel |
| 1449 | * command line parameter. See Documentation/filesystems/nfsroot.txt. | 1449 | * command line parameter. See Documentation/filesystems/nfs/nfsroot.txt. |
| 1450 | */ | 1450 | */ |
| 1451 | static int __init ic_proto_name(char *name) | 1451 | static int __init ic_proto_name(char *name) |
| 1452 | { | 1452 | { |
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index 06632762ba5f..90203e1b9187 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c | |||
| @@ -925,10 +925,10 @@ static int get_info(struct net *net, void __user *user, int *len, int compat) | |||
| 925 | if (t && !IS_ERR(t)) { | 925 | if (t && !IS_ERR(t)) { |
| 926 | struct arpt_getinfo info; | 926 | struct arpt_getinfo info; |
| 927 | const struct xt_table_info *private = t->private; | 927 | const struct xt_table_info *private = t->private; |
| 928 | |||
| 929 | #ifdef CONFIG_COMPAT | 928 | #ifdef CONFIG_COMPAT |
| 929 | struct xt_table_info tmp; | ||
| 930 | |||
| 930 | if (compat) { | 931 | if (compat) { |
| 931 | struct xt_table_info tmp; | ||
| 932 | ret = compat_table_info(private, &tmp); | 932 | ret = compat_table_info(private, &tmp); |
| 933 | xt_compat_flush_offsets(NFPROTO_ARP); | 933 | xt_compat_flush_offsets(NFPROTO_ARP); |
| 934 | private = &tmp; | 934 | private = &tmp; |
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index 572330a552ef..3ce53cf13d5a 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c | |||
| @@ -1132,10 +1132,10 @@ static int get_info(struct net *net, void __user *user, int *len, int compat) | |||
| 1132 | if (t && !IS_ERR(t)) { | 1132 | if (t && !IS_ERR(t)) { |
| 1133 | struct ipt_getinfo info; | 1133 | struct ipt_getinfo info; |
| 1134 | const struct xt_table_info *private = t->private; | 1134 | const struct xt_table_info *private = t->private; |
| 1135 | |||
| 1136 | #ifdef CONFIG_COMPAT | 1135 | #ifdef CONFIG_COMPAT |
| 1136 | struct xt_table_info tmp; | ||
| 1137 | |||
| 1137 | if (compat) { | 1138 | if (compat) { |
| 1138 | struct xt_table_info tmp; | ||
| 1139 | ret = compat_table_info(private, &tmp); | 1139 | ret = compat_table_info(private, &tmp); |
| 1140 | xt_compat_flush_offsets(AF_INET); | 1140 | xt_compat_flush_offsets(AF_INET); |
| 1141 | private = &tmp; | 1141 | private = &tmp; |
diff --git a/net/ipv4/netfilter/ipt_ECN.c b/net/ipv4/netfilter/ipt_ECN.c index 549e206cdd42..ea5cea2415c1 100644 --- a/net/ipv4/netfilter/ipt_ECN.c +++ b/net/ipv4/netfilter/ipt_ECN.c | |||
| @@ -50,7 +50,7 @@ set_ect_tcp(struct sk_buff *skb, const struct ipt_ECN_info *einfo) | |||
| 50 | struct tcphdr _tcph, *tcph; | 50 | struct tcphdr _tcph, *tcph; |
| 51 | __be16 oldval; | 51 | __be16 oldval; |
| 52 | 52 | ||
| 53 | /* Not enought header? */ | 53 | /* Not enough header? */ |
| 54 | tcph = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_tcph), &_tcph); | 54 | tcph = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_tcph), &_tcph); |
| 55 | if (!tcph) | 55 | if (!tcph) |
| 56 | return false; | 56 | return false; |
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c index d171b123a656..d1ea38a7c490 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | |||
| @@ -210,7 +210,7 @@ static ctl_table ip_ct_sysctl_table[] = { | |||
| 210 | }, | 210 | }, |
| 211 | { | 211 | { |
| 212 | .procname = "ip_conntrack_buckets", | 212 | .procname = "ip_conntrack_buckets", |
| 213 | .data = &nf_conntrack_htable_size, | 213 | .data = &init_net.ct.htable_size, |
| 214 | .maxlen = sizeof(unsigned int), | 214 | .maxlen = sizeof(unsigned int), |
| 215 | .mode = 0444, | 215 | .mode = 0444, |
| 216 | .proc_handler = proc_dointvec, | 216 | .proc_handler = proc_dointvec, |
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c index 8668a3defda6..2fb7b76da94f 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | |||
| @@ -32,7 +32,7 @@ static struct hlist_nulls_node *ct_get_first(struct seq_file *seq) | |||
| 32 | struct hlist_nulls_node *n; | 32 | struct hlist_nulls_node *n; |
| 33 | 33 | ||
| 34 | for (st->bucket = 0; | 34 | for (st->bucket = 0; |
| 35 | st->bucket < nf_conntrack_htable_size; | 35 | st->bucket < net->ct.htable_size; |
| 36 | st->bucket++) { | 36 | st->bucket++) { |
| 37 | n = rcu_dereference(net->ct.hash[st->bucket].first); | 37 | n = rcu_dereference(net->ct.hash[st->bucket].first); |
| 38 | if (!is_a_nulls(n)) | 38 | if (!is_a_nulls(n)) |
| @@ -50,7 +50,7 @@ static struct hlist_nulls_node *ct_get_next(struct seq_file *seq, | |||
| 50 | head = rcu_dereference(head->next); | 50 | head = rcu_dereference(head->next); |
| 51 | while (is_a_nulls(head)) { | 51 | while (is_a_nulls(head)) { |
| 52 | if (likely(get_nulls_value(head) == st->bucket)) { | 52 | if (likely(get_nulls_value(head) == st->bucket)) { |
| 53 | if (++st->bucket >= nf_conntrack_htable_size) | 53 | if (++st->bucket >= net->ct.htable_size) |
| 54 | return NULL; | 54 | return NULL; |
| 55 | } | 55 | } |
| 56 | head = rcu_dereference(net->ct.hash[st->bucket].first); | 56 | head = rcu_dereference(net->ct.hash[st->bucket].first); |
diff --git a/net/ipv4/netfilter/nf_defrag_ipv4.c b/net/ipv4/netfilter/nf_defrag_ipv4.c index fa2d6b6fc3e5..331ead3ebd1b 100644 --- a/net/ipv4/netfilter/nf_defrag_ipv4.c +++ b/net/ipv4/netfilter/nf_defrag_ipv4.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include <net/route.h> | 14 | #include <net/route.h> |
| 15 | #include <net/ip.h> | 15 | #include <net/ip.h> |
| 16 | 16 | ||
| 17 | #include <linux/netfilter_bridge.h> | ||
| 17 | #include <linux/netfilter_ipv4.h> | 18 | #include <linux/netfilter_ipv4.h> |
| 18 | #include <net/netfilter/ipv4/nf_defrag_ipv4.h> | 19 | #include <net/netfilter/ipv4/nf_defrag_ipv4.h> |
| 19 | 20 | ||
| @@ -34,6 +35,20 @@ static int nf_ct_ipv4_gather_frags(struct sk_buff *skb, u_int32_t user) | |||
| 34 | return err; | 35 | return err; |
| 35 | } | 36 | } |
| 36 | 37 | ||
| 38 | static enum ip_defrag_users nf_ct_defrag_user(unsigned int hooknum, | ||
| 39 | struct sk_buff *skb) | ||
| 40 | { | ||
| 41 | #ifdef CONFIG_BRIDGE_NETFILTER | ||
| 42 | if (skb->nf_bridge && | ||
| 43 | skb->nf_bridge->mask & BRNF_NF_BRIDGE_PREROUTING) | ||
| 44 | return IP_DEFRAG_CONNTRACK_BRIDGE_IN; | ||
| 45 | #endif | ||
| 46 | if (hooknum == NF_INET_PRE_ROUTING) | ||
| 47 | return IP_DEFRAG_CONNTRACK_IN; | ||
| 48 | else | ||
| 49 | return IP_DEFRAG_CONNTRACK_OUT; | ||
| 50 | } | ||
| 51 | |||
| 37 | static unsigned int ipv4_conntrack_defrag(unsigned int hooknum, | 52 | static unsigned int ipv4_conntrack_defrag(unsigned int hooknum, |
| 38 | struct sk_buff *skb, | 53 | struct sk_buff *skb, |
| 39 | const struct net_device *in, | 54 | const struct net_device *in, |
| @@ -50,10 +65,8 @@ static unsigned int ipv4_conntrack_defrag(unsigned int hooknum, | |||
| 50 | #endif | 65 | #endif |
| 51 | /* Gather fragments. */ | 66 | /* Gather fragments. */ |
| 52 | if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) { | 67 | if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) { |
| 53 | if (nf_ct_ipv4_gather_frags(skb, | 68 | enum ip_defrag_users user = nf_ct_defrag_user(hooknum, skb); |
| 54 | hooknum == NF_INET_PRE_ROUTING ? | 69 | if (nf_ct_ipv4_gather_frags(skb, user)) |
| 55 | IP_DEFRAG_CONNTRACK_IN : | ||
| 56 | IP_DEFRAG_CONNTRACK_OUT)) | ||
| 57 | return NF_STOLEN; | 70 | return NF_STOLEN; |
| 58 | } | 71 | } |
| 59 | return NF_ACCEPT; | 72 | return NF_ACCEPT; |
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c index fe1a64479dd0..26066a2327ad 100644 --- a/net/ipv4/netfilter/nf_nat_core.c +++ b/net/ipv4/netfilter/nf_nat_core.c | |||
| @@ -35,9 +35,6 @@ static DEFINE_SPINLOCK(nf_nat_lock); | |||
| 35 | 35 | ||
| 36 | static struct nf_conntrack_l3proto *l3proto __read_mostly; | 36 | static struct nf_conntrack_l3proto *l3proto __read_mostly; |
| 37 | 37 | ||
| 38 | /* Calculated at init based on memory size */ | ||
| 39 | static unsigned int nf_nat_htable_size __read_mostly; | ||
| 40 | |||
| 41 | #define MAX_IP_NAT_PROTO 256 | 38 | #define MAX_IP_NAT_PROTO 256 |
| 42 | static const struct nf_nat_protocol *nf_nat_protos[MAX_IP_NAT_PROTO] | 39 | static const struct nf_nat_protocol *nf_nat_protos[MAX_IP_NAT_PROTO] |
| 43 | __read_mostly; | 40 | __read_mostly; |
| @@ -72,7 +69,7 @@ EXPORT_SYMBOL_GPL(nf_nat_proto_put); | |||
| 72 | 69 | ||
| 73 | /* We keep an extra hash for each conntrack, for fast searching. */ | 70 | /* We keep an extra hash for each conntrack, for fast searching. */ |
| 74 | static inline unsigned int | 71 | static inline unsigned int |
| 75 | hash_by_src(const struct nf_conntrack_tuple *tuple) | 72 | hash_by_src(const struct net *net, const struct nf_conntrack_tuple *tuple) |
| 76 | { | 73 | { |
| 77 | unsigned int hash; | 74 | unsigned int hash; |
| 78 | 75 | ||
| @@ -80,7 +77,7 @@ hash_by_src(const struct nf_conntrack_tuple *tuple) | |||
| 80 | hash = jhash_3words((__force u32)tuple->src.u3.ip, | 77 | hash = jhash_3words((__force u32)tuple->src.u3.ip, |
| 81 | (__force u32)tuple->src.u.all, | 78 | (__force u32)tuple->src.u.all, |
| 82 | tuple->dst.protonum, 0); | 79 | tuple->dst.protonum, 0); |
| 83 | return ((u64)hash * nf_nat_htable_size) >> 32; | 80 | return ((u64)hash * net->ipv4.nat_htable_size) >> 32; |
| 84 | } | 81 | } |
| 85 | 82 | ||
| 86 | /* Is this tuple already taken? (not by us) */ | 83 | /* Is this tuple already taken? (not by us) */ |
| @@ -147,7 +144,7 @@ find_appropriate_src(struct net *net, | |||
| 147 | struct nf_conntrack_tuple *result, | 144 | struct nf_conntrack_tuple *result, |
| 148 | const struct nf_nat_range *range) | 145 | const struct nf_nat_range *range) |
| 149 | { | 146 | { |
| 150 | unsigned int h = hash_by_src(tuple); | 147 | unsigned int h = hash_by_src(net, tuple); |
| 151 | const struct nf_conn_nat *nat; | 148 | const struct nf_conn_nat *nat; |
| 152 | const struct nf_conn *ct; | 149 | const struct nf_conn *ct; |
| 153 | const struct hlist_node *n; | 150 | const struct hlist_node *n; |
| @@ -330,7 +327,7 @@ nf_nat_setup_info(struct nf_conn *ct, | |||
| 330 | if (have_to_hash) { | 327 | if (have_to_hash) { |
| 331 | unsigned int srchash; | 328 | unsigned int srchash; |
| 332 | 329 | ||
| 333 | srchash = hash_by_src(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); | 330 | srchash = hash_by_src(net, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); |
| 334 | spin_lock_bh(&nf_nat_lock); | 331 | spin_lock_bh(&nf_nat_lock); |
| 335 | /* nf_conntrack_alter_reply might re-allocate exntension aera */ | 332 | /* nf_conntrack_alter_reply might re-allocate exntension aera */ |
| 336 | nat = nfct_nat(ct); | 333 | nat = nfct_nat(ct); |
| @@ -679,8 +676,10 @@ nfnetlink_parse_nat_setup(struct nf_conn *ct, | |||
| 679 | 676 | ||
| 680 | static int __net_init nf_nat_net_init(struct net *net) | 677 | static int __net_init nf_nat_net_init(struct net *net) |
| 681 | { | 678 | { |
| 682 | net->ipv4.nat_bysource = nf_ct_alloc_hashtable(&nf_nat_htable_size, | 679 | /* Leave them the same for the moment. */ |
| 683 | &net->ipv4.nat_vmalloced, 0); | 680 | net->ipv4.nat_htable_size = net->ct.htable_size; |
| 681 | net->ipv4.nat_bysource = nf_ct_alloc_hashtable(&net->ipv4.nat_htable_size, | ||
| 682 | &net->ipv4.nat_vmalloced, 0); | ||
| 684 | if (!net->ipv4.nat_bysource) | 683 | if (!net->ipv4.nat_bysource) |
| 685 | return -ENOMEM; | 684 | return -ENOMEM; |
| 686 | return 0; | 685 | return 0; |
| @@ -703,7 +702,7 @@ static void __net_exit nf_nat_net_exit(struct net *net) | |||
| 703 | nf_ct_iterate_cleanup(net, &clean_nat, NULL); | 702 | nf_ct_iterate_cleanup(net, &clean_nat, NULL); |
| 704 | synchronize_rcu(); | 703 | synchronize_rcu(); |
| 705 | nf_ct_free_hashtable(net->ipv4.nat_bysource, net->ipv4.nat_vmalloced, | 704 | nf_ct_free_hashtable(net->ipv4.nat_bysource, net->ipv4.nat_vmalloced, |
| 706 | nf_nat_htable_size); | 705 | net->ipv4.nat_htable_size); |
| 707 | } | 706 | } |
| 708 | 707 | ||
| 709 | static struct pernet_operations nf_nat_net_ops = { | 708 | static struct pernet_operations nf_nat_net_ops = { |
| @@ -724,9 +723,6 @@ static int __init nf_nat_init(void) | |||
| 724 | return ret; | 723 | return ret; |
| 725 | } | 724 | } |
| 726 | 725 | ||
| 727 | /* Leave them the same for the moment. */ | ||
| 728 | nf_nat_htable_size = nf_conntrack_htable_size; | ||
| 729 | |||
| 730 | ret = register_pernet_subsys(&nf_nat_net_ops); | 726 | ret = register_pernet_subsys(&nf_nat_net_ops); |
| 731 | if (ret < 0) | 727 | if (ret < 0) |
| 732 | goto cleanup_extend; | 728 | goto cleanup_extend; |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index e446496f564f..4f11faa5c824 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
| @@ -287,12 +287,12 @@ static struct rtable *rt_cache_get_first(struct seq_file *seq) | |||
| 287 | if (!rt_hash_table[st->bucket].chain) | 287 | if (!rt_hash_table[st->bucket].chain) |
| 288 | continue; | 288 | continue; |
| 289 | rcu_read_lock_bh(); | 289 | rcu_read_lock_bh(); |
| 290 | r = rcu_dereference(rt_hash_table[st->bucket].chain); | 290 | r = rcu_dereference_bh(rt_hash_table[st->bucket].chain); |
| 291 | while (r) { | 291 | while (r) { |
| 292 | if (dev_net(r->u.dst.dev) == seq_file_net(seq) && | 292 | if (dev_net(r->u.dst.dev) == seq_file_net(seq) && |
| 293 | r->rt_genid == st->genid) | 293 | r->rt_genid == st->genid) |
| 294 | return r; | 294 | return r; |
| 295 | r = rcu_dereference(r->u.dst.rt_next); | 295 | r = rcu_dereference_bh(r->u.dst.rt_next); |
| 296 | } | 296 | } |
| 297 | rcu_read_unlock_bh(); | 297 | rcu_read_unlock_bh(); |
| 298 | } | 298 | } |
| @@ -314,7 +314,7 @@ static struct rtable *__rt_cache_get_next(struct seq_file *seq, | |||
| 314 | rcu_read_lock_bh(); | 314 | rcu_read_lock_bh(); |
| 315 | r = rt_hash_table[st->bucket].chain; | 315 | r = rt_hash_table[st->bucket].chain; |
| 316 | } | 316 | } |
| 317 | return rcu_dereference(r); | 317 | return rcu_dereference_bh(r); |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | static struct rtable *rt_cache_get_next(struct seq_file *seq, | 320 | static struct rtable *rt_cache_get_next(struct seq_file *seq, |
| @@ -586,7 +586,9 @@ static void __net_exit ip_rt_do_proc_exit(struct net *net) | |||
| 586 | { | 586 | { |
| 587 | remove_proc_entry("rt_cache", net->proc_net_stat); | 587 | remove_proc_entry("rt_cache", net->proc_net_stat); |
| 588 | remove_proc_entry("rt_cache", net->proc_net); | 588 | remove_proc_entry("rt_cache", net->proc_net); |
| 589 | #ifdef CONFIG_NET_CLS_ROUTE | ||
| 589 | remove_proc_entry("rt_acct", net->proc_net); | 590 | remove_proc_entry("rt_acct", net->proc_net); |
| 591 | #endif | ||
| 590 | } | 592 | } |
| 591 | 593 | ||
| 592 | static struct pernet_operations ip_rt_proc_ops __net_initdata = { | 594 | static struct pernet_operations ip_rt_proc_ops __net_initdata = { |
| @@ -2687,8 +2689,8 @@ int __ip_route_output_key(struct net *net, struct rtable **rp, | |||
| 2687 | hash = rt_hash(flp->fl4_dst, flp->fl4_src, flp->oif, rt_genid(net)); | 2689 | hash = rt_hash(flp->fl4_dst, flp->fl4_src, flp->oif, rt_genid(net)); |
| 2688 | 2690 | ||
| 2689 | rcu_read_lock_bh(); | 2691 | rcu_read_lock_bh(); |
| 2690 | for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; | 2692 | for (rth = rcu_dereference_bh(rt_hash_table[hash].chain); rth; |
| 2691 | rth = rcu_dereference(rth->u.dst.rt_next)) { | 2693 | rth = rcu_dereference_bh(rth->u.dst.rt_next)) { |
| 2692 | if (rth->fl.fl4_dst == flp->fl4_dst && | 2694 | if (rth->fl.fl4_dst == flp->fl4_dst && |
| 2693 | rth->fl.fl4_src == flp->fl4_src && | 2695 | rth->fl.fl4_src == flp->fl4_src && |
| 2694 | rth->fl.iif == 0 && | 2696 | rth->fl.iif == 0 && |
| @@ -3006,8 +3008,8 @@ int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 3006 | if (!rt_hash_table[h].chain) | 3008 | if (!rt_hash_table[h].chain) |
| 3007 | continue; | 3009 | continue; |
| 3008 | rcu_read_lock_bh(); | 3010 | rcu_read_lock_bh(); |
| 3009 | for (rt = rcu_dereference(rt_hash_table[h].chain), idx = 0; rt; | 3011 | for (rt = rcu_dereference_bh(rt_hash_table[h].chain), idx = 0; rt; |
| 3010 | rt = rcu_dereference(rt->u.dst.rt_next), idx++) { | 3012 | rt = rcu_dereference_bh(rt->u.dst.rt_next), idx++) { |
| 3011 | if (!net_eq(dev_net(rt->u.dst.dev), net) || idx < s_idx) | 3013 | if (!net_eq(dev_net(rt->u.dst.dev), net) || idx < s_idx) |
| 3012 | continue; | 3014 | continue; |
| 3013 | if (rt_is_expired(rt)) | 3015 | if (rt_is_expired(rt)) |
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index 26399ad2a289..66fd80ef2473 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c | |||
| @@ -277,6 +277,13 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, | |||
| 277 | 277 | ||
| 278 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESRECV); | 278 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESRECV); |
| 279 | 279 | ||
| 280 | /* check for timestamp cookie support */ | ||
| 281 | memset(&tcp_opt, 0, sizeof(tcp_opt)); | ||
| 282 | tcp_parse_options(skb, &tcp_opt, &hash_location, 0); | ||
| 283 | |||
| 284 | if (tcp_opt.saw_tstamp) | ||
| 285 | cookie_check_timestamp(&tcp_opt); | ||
| 286 | |||
| 280 | ret = NULL; | 287 | ret = NULL; |
| 281 | req = inet_reqsk_alloc(&tcp_request_sock_ops); /* for safety */ | 288 | req = inet_reqsk_alloc(&tcp_request_sock_ops); /* for safety */ |
| 282 | if (!req) | 289 | if (!req) |
| @@ -292,6 +299,12 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, | |||
| 292 | ireq->loc_addr = ip_hdr(skb)->daddr; | 299 | ireq->loc_addr = ip_hdr(skb)->daddr; |
| 293 | ireq->rmt_addr = ip_hdr(skb)->saddr; | 300 | ireq->rmt_addr = ip_hdr(skb)->saddr; |
| 294 | ireq->ecn_ok = 0; | 301 | ireq->ecn_ok = 0; |
| 302 | ireq->snd_wscale = tcp_opt.snd_wscale; | ||
| 303 | ireq->rcv_wscale = tcp_opt.rcv_wscale; | ||
| 304 | ireq->sack_ok = tcp_opt.sack_ok; | ||
| 305 | ireq->wscale_ok = tcp_opt.wscale_ok; | ||
| 306 | ireq->tstamp_ok = tcp_opt.saw_tstamp; | ||
| 307 | req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0; | ||
| 295 | 308 | ||
| 296 | /* We throwed the options of the initial SYN away, so we hope | 309 | /* We throwed the options of the initial SYN away, so we hope |
| 297 | * the ACK carries the same options again (see RFC1122 4.2.3.8) | 310 | * the ACK carries the same options again (see RFC1122 4.2.3.8) |
| @@ -340,20 +353,6 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, | |||
| 340 | } | 353 | } |
| 341 | } | 354 | } |
| 342 | 355 | ||
| 343 | /* check for timestamp cookie support */ | ||
| 344 | memset(&tcp_opt, 0, sizeof(tcp_opt)); | ||
| 345 | tcp_parse_options(skb, &tcp_opt, &hash_location, 0, &rt->u.dst); | ||
| 346 | |||
| 347 | if (tcp_opt.saw_tstamp) | ||
| 348 | cookie_check_timestamp(&tcp_opt); | ||
| 349 | |||
| 350 | ireq->snd_wscale = tcp_opt.snd_wscale; | ||
| 351 | ireq->rcv_wscale = tcp_opt.rcv_wscale; | ||
| 352 | ireq->sack_ok = tcp_opt.sack_ok; | ||
| 353 | ireq->wscale_ok = tcp_opt.wscale_ok; | ||
| 354 | ireq->tstamp_ok = tcp_opt.saw_tstamp; | ||
| 355 | req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0; | ||
| 356 | |||
| 357 | /* Try to redo what tcp_v4_send_synack did. */ | 356 | /* Try to redo what tcp_v4_send_synack did. */ |
| 358 | req->window_clamp = tp->window_clamp ? :dst_metric(&rt->u.dst, RTAX_WINDOW); | 357 | req->window_clamp = tp->window_clamp ? :dst_metric(&rt->u.dst, RTAX_WINDOW); |
| 359 | 358 | ||
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index c8666b70cde0..b0a26bb25e2e 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
| @@ -2540,11 +2540,6 @@ static int do_tcp_getsockopt(struct sock *sk, int level, | |||
| 2540 | ctd.tcpct_cookie_desired = cvp->cookie_desired; | 2540 | ctd.tcpct_cookie_desired = cvp->cookie_desired; |
| 2541 | ctd.tcpct_s_data_desired = cvp->s_data_desired; | 2541 | ctd.tcpct_s_data_desired = cvp->s_data_desired; |
| 2542 | 2542 | ||
| 2543 | /* Cookie(s) saved, return as nonce */ | ||
| 2544 | if (sizeof(ctd.tcpct_value) < cvp->cookie_pair_size) { | ||
| 2545 | /* impossible? */ | ||
| 2546 | return -EINVAL; | ||
| 2547 | } | ||
| 2548 | memcpy(&ctd.tcpct_value[0], &cvp->cookie_pair[0], | 2543 | memcpy(&ctd.tcpct_value[0], &cvp->cookie_pair[0], |
| 2549 | cvp->cookie_pair_size); | 2544 | cvp->cookie_pair_size); |
| 2550 | ctd.tcpct_used = cvp->cookie_pair_size; | 2545 | ctd.tcpct_used = cvp->cookie_pair_size; |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 57ae96a04220..3fddc69ccccc 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
| @@ -2717,6 +2717,35 @@ static void tcp_try_undo_dsack(struct sock *sk) | |||
| 2717 | } | 2717 | } |
| 2718 | } | 2718 | } |
| 2719 | 2719 | ||
| 2720 | /* We can clear retrans_stamp when there are no retransmissions in the | ||
| 2721 | * window. It would seem that it is trivially available for us in | ||
| 2722 | * tp->retrans_out, however, that kind of assumptions doesn't consider | ||
| 2723 | * what will happen if errors occur when sending retransmission for the | ||
| 2724 | * second time. ...It could the that such segment has only | ||
| 2725 | * TCPCB_EVER_RETRANS set at the present time. It seems that checking | ||
| 2726 | * the head skb is enough except for some reneging corner cases that | ||
| 2727 | * are not worth the effort. | ||
| 2728 | * | ||
| 2729 | * Main reason for all this complexity is the fact that connection dying | ||
| 2730 | * time now depends on the validity of the retrans_stamp, in particular, | ||
| 2731 | * that successive retransmissions of a segment must not advance | ||
| 2732 | * retrans_stamp under any conditions. | ||
| 2733 | */ | ||
| 2734 | static int tcp_any_retrans_done(struct sock *sk) | ||
| 2735 | { | ||
| 2736 | struct tcp_sock *tp = tcp_sk(sk); | ||
| 2737 | struct sk_buff *skb; | ||
| 2738 | |||
| 2739 | if (tp->retrans_out) | ||
| 2740 | return 1; | ||
| 2741 | |||
| 2742 | skb = tcp_write_queue_head(sk); | ||
| 2743 | if (unlikely(skb && TCP_SKB_CB(skb)->sacked & TCPCB_EVER_RETRANS)) | ||
| 2744 | return 1; | ||
| 2745 | |||
| 2746 | return 0; | ||
| 2747 | } | ||
| 2748 | |||
| 2720 | /* Undo during fast recovery after partial ACK. */ | 2749 | /* Undo during fast recovery after partial ACK. */ |
| 2721 | 2750 | ||
| 2722 | static int tcp_try_undo_partial(struct sock *sk, int acked) | 2751 | static int tcp_try_undo_partial(struct sock *sk, int acked) |
| @@ -2729,7 +2758,7 @@ static int tcp_try_undo_partial(struct sock *sk, int acked) | |||
| 2729 | /* Plain luck! Hole if filled with delayed | 2758 | /* Plain luck! Hole if filled with delayed |
| 2730 | * packet, rather than with a retransmit. | 2759 | * packet, rather than with a retransmit. |
| 2731 | */ | 2760 | */ |
| 2732 | if (tp->retrans_out == 0) | 2761 | if (!tcp_any_retrans_done(sk)) |
| 2733 | tp->retrans_stamp = 0; | 2762 | tp->retrans_stamp = 0; |
| 2734 | 2763 | ||
| 2735 | tcp_update_reordering(sk, tcp_fackets_out(tp) + acked, 1); | 2764 | tcp_update_reordering(sk, tcp_fackets_out(tp) + acked, 1); |
| @@ -2788,7 +2817,7 @@ static void tcp_try_keep_open(struct sock *sk) | |||
| 2788 | struct tcp_sock *tp = tcp_sk(sk); | 2817 | struct tcp_sock *tp = tcp_sk(sk); |
| 2789 | int state = TCP_CA_Open; | 2818 | int state = TCP_CA_Open; |
| 2790 | 2819 | ||
| 2791 | if (tcp_left_out(tp) || tp->retrans_out || tp->undo_marker) | 2820 | if (tcp_left_out(tp) || tcp_any_retrans_done(sk) || tp->undo_marker) |
| 2792 | state = TCP_CA_Disorder; | 2821 | state = TCP_CA_Disorder; |
| 2793 | 2822 | ||
| 2794 | if (inet_csk(sk)->icsk_ca_state != state) { | 2823 | if (inet_csk(sk)->icsk_ca_state != state) { |
| @@ -2803,7 +2832,7 @@ static void tcp_try_to_open(struct sock *sk, int flag) | |||
| 2803 | 2832 | ||
| 2804 | tcp_verify_left_out(tp); | 2833 | tcp_verify_left_out(tp); |
| 2805 | 2834 | ||
| 2806 | if (!tp->frto_counter && tp->retrans_out == 0) | 2835 | if (!tp->frto_counter && !tcp_any_retrans_done(sk)) |
| 2807 | tp->retrans_stamp = 0; | 2836 | tp->retrans_stamp = 0; |
| 2808 | 2837 | ||
| 2809 | if (flag & FLAG_ECE) | 2838 | if (flag & FLAG_ECE) |
| @@ -3698,7 +3727,7 @@ old_ack: | |||
| 3698 | * the fast version below fails. | 3727 | * the fast version below fails. |
| 3699 | */ | 3728 | */ |
| 3700 | void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx, | 3729 | void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx, |
| 3701 | u8 **hvpp, int estab, struct dst_entry *dst) | 3730 | u8 **hvpp, int estab) |
| 3702 | { | 3731 | { |
| 3703 | unsigned char *ptr; | 3732 | unsigned char *ptr; |
| 3704 | struct tcphdr *th = tcp_hdr(skb); | 3733 | struct tcphdr *th = tcp_hdr(skb); |
| @@ -3737,8 +3766,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx, | |||
| 3737 | break; | 3766 | break; |
| 3738 | case TCPOPT_WINDOW: | 3767 | case TCPOPT_WINDOW: |
| 3739 | if (opsize == TCPOLEN_WINDOW && th->syn && | 3768 | if (opsize == TCPOLEN_WINDOW && th->syn && |
| 3740 | !estab && sysctl_tcp_window_scaling && | 3769 | !estab && sysctl_tcp_window_scaling) { |
| 3741 | !dst_feature(dst, RTAX_FEATURE_NO_WSCALE)) { | ||
| 3742 | __u8 snd_wscale = *(__u8 *)ptr; | 3770 | __u8 snd_wscale = *(__u8 *)ptr; |
| 3743 | opt_rx->wscale_ok = 1; | 3771 | opt_rx->wscale_ok = 1; |
| 3744 | if (snd_wscale > 14) { | 3772 | if (snd_wscale > 14) { |
| @@ -3754,8 +3782,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx, | |||
| 3754 | case TCPOPT_TIMESTAMP: | 3782 | case TCPOPT_TIMESTAMP: |
| 3755 | if ((opsize == TCPOLEN_TIMESTAMP) && | 3783 | if ((opsize == TCPOLEN_TIMESTAMP) && |
| 3756 | ((estab && opt_rx->tstamp_ok) || | 3784 | ((estab && opt_rx->tstamp_ok) || |
| 3757 | (!estab && sysctl_tcp_timestamps && | 3785 | (!estab && sysctl_tcp_timestamps))) { |
| 3758 | !dst_feature(dst, RTAX_FEATURE_NO_TSTAMP)))) { | ||
| 3759 | opt_rx->saw_tstamp = 1; | 3786 | opt_rx->saw_tstamp = 1; |
| 3760 | opt_rx->rcv_tsval = get_unaligned_be32(ptr); | 3787 | opt_rx->rcv_tsval = get_unaligned_be32(ptr); |
| 3761 | opt_rx->rcv_tsecr = get_unaligned_be32(ptr + 4); | 3788 | opt_rx->rcv_tsecr = get_unaligned_be32(ptr + 4); |
| @@ -3763,8 +3790,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx, | |||
| 3763 | break; | 3790 | break; |
| 3764 | case TCPOPT_SACK_PERM: | 3791 | case TCPOPT_SACK_PERM: |
| 3765 | if (opsize == TCPOLEN_SACK_PERM && th->syn && | 3792 | if (opsize == TCPOLEN_SACK_PERM && th->syn && |
| 3766 | !estab && sysctl_tcp_sack && | 3793 | !estab && sysctl_tcp_sack) { |
| 3767 | !dst_feature(dst, RTAX_FEATURE_NO_SACK)) { | ||
| 3768 | opt_rx->sack_ok = 1; | 3794 | opt_rx->sack_ok = 1; |
| 3769 | tcp_sack_reset(opt_rx); | 3795 | tcp_sack_reset(opt_rx); |
| 3770 | } | 3796 | } |
| @@ -3849,7 +3875,7 @@ static int tcp_fast_parse_options(struct sk_buff *skb, struct tcphdr *th, | |||
| 3849 | if (tcp_parse_aligned_timestamp(tp, th)) | 3875 | if (tcp_parse_aligned_timestamp(tp, th)) |
| 3850 | return 1; | 3876 | return 1; |
| 3851 | } | 3877 | } |
| 3852 | tcp_parse_options(skb, &tp->rx_opt, hvpp, 1, NULL); | 3878 | tcp_parse_options(skb, &tp->rx_opt, hvpp, 1); |
| 3853 | return 1; | 3879 | return 1; |
| 3854 | } | 3880 | } |
| 3855 | 3881 | ||
| @@ -4104,10 +4130,8 @@ static inline int tcp_sack_extend(struct tcp_sack_block *sp, u32 seq, | |||
| 4104 | static void tcp_dsack_set(struct sock *sk, u32 seq, u32 end_seq) | 4130 | static void tcp_dsack_set(struct sock *sk, u32 seq, u32 end_seq) |
| 4105 | { | 4131 | { |
| 4106 | struct tcp_sock *tp = tcp_sk(sk); | 4132 | struct tcp_sock *tp = tcp_sk(sk); |
| 4107 | struct dst_entry *dst = __sk_dst_get(sk); | ||
| 4108 | 4133 | ||
| 4109 | if (tcp_is_sack(tp) && sysctl_tcp_dsack && | 4134 | if (tcp_is_sack(tp) && sysctl_tcp_dsack) { |
| 4110 | !dst_feature(dst, RTAX_FEATURE_NO_DSACK)) { | ||
| 4111 | int mib_idx; | 4135 | int mib_idx; |
| 4112 | 4136 | ||
| 4113 | if (before(seq, tp->rcv_nxt)) | 4137 | if (before(seq, tp->rcv_nxt)) |
| @@ -4136,15 +4160,13 @@ static void tcp_dsack_extend(struct sock *sk, u32 seq, u32 end_seq) | |||
| 4136 | static void tcp_send_dupack(struct sock *sk, struct sk_buff *skb) | 4160 | static void tcp_send_dupack(struct sock *sk, struct sk_buff *skb) |
| 4137 | { | 4161 | { |
| 4138 | struct tcp_sock *tp = tcp_sk(sk); | 4162 | struct tcp_sock *tp = tcp_sk(sk); |
| 4139 | struct dst_entry *dst = __sk_dst_get(sk); | ||
| 4140 | 4163 | ||
| 4141 | if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq && | 4164 | if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq && |
| 4142 | before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) { | 4165 | before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) { |
| 4143 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_DELAYEDACKLOST); | 4166 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_DELAYEDACKLOST); |
| 4144 | tcp_enter_quickack_mode(sk); | 4167 | tcp_enter_quickack_mode(sk); |
| 4145 | 4168 | ||
| 4146 | if (tcp_is_sack(tp) && sysctl_tcp_dsack && | 4169 | if (tcp_is_sack(tp) && sysctl_tcp_dsack) { |
| 4147 | !dst_feature(dst, RTAX_FEATURE_NO_DSACK)) { | ||
| 4148 | u32 end_seq = TCP_SKB_CB(skb)->end_seq; | 4170 | u32 end_seq = TCP_SKB_CB(skb)->end_seq; |
| 4149 | 4171 | ||
| 4150 | if (after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt)) | 4172 | if (after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt)) |
| @@ -5399,11 +5421,10 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, | |||
| 5399 | u8 *hash_location; | 5421 | u8 *hash_location; |
| 5400 | struct inet_connection_sock *icsk = inet_csk(sk); | 5422 | struct inet_connection_sock *icsk = inet_csk(sk); |
| 5401 | struct tcp_sock *tp = tcp_sk(sk); | 5423 | struct tcp_sock *tp = tcp_sk(sk); |
| 5402 | struct dst_entry *dst = __sk_dst_get(sk); | ||
| 5403 | struct tcp_cookie_values *cvp = tp->cookie_values; | 5424 | struct tcp_cookie_values *cvp = tp->cookie_values; |
| 5404 | int saved_clamp = tp->rx_opt.mss_clamp; | 5425 | int saved_clamp = tp->rx_opt.mss_clamp; |
| 5405 | 5426 | ||
| 5406 | tcp_parse_options(skb, &tp->rx_opt, &hash_location, 0, dst); | 5427 | tcp_parse_options(skb, &tp->rx_opt, &hash_location, 0); |
| 5407 | 5428 | ||
| 5408 | if (th->ack) { | 5429 | if (th->ack) { |
| 5409 | /* rfc793: | 5430 | /* rfc793: |
| @@ -5762,11 +5783,9 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, | |||
| 5762 | 5783 | ||
| 5763 | /* tcp_ack considers this ACK as duplicate | 5784 | /* tcp_ack considers this ACK as duplicate |
| 5764 | * and does not calculate rtt. | 5785 | * and does not calculate rtt. |
| 5765 | * Fix it at least with timestamps. | 5786 | * Force it here. |
| 5766 | */ | 5787 | */ |
| 5767 | if (tp->rx_opt.saw_tstamp && | 5788 | tcp_ack_update_rtt(sk, 0, 0); |
| 5768 | tp->rx_opt.rcv_tsecr && !tp->srtt) | ||
| 5769 | tcp_ack_saw_tstamp(sk, 0); | ||
| 5770 | 5789 | ||
| 5771 | if (tp->rx_opt.tstamp_ok) | 5790 | if (tp->rx_opt.tstamp_ok) |
| 5772 | tp->advmss -= TCPOLEN_TSTAMP_ALIGNED; | 5791 | tp->advmss -= TCPOLEN_TSTAMP_ALIGNED; |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 29002ab26e0d..65b8ebfd078a 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
| @@ -1262,20 +1262,10 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
| 1262 | tcp_rsk(req)->af_specific = &tcp_request_sock_ipv4_ops; | 1262 | tcp_rsk(req)->af_specific = &tcp_request_sock_ipv4_ops; |
| 1263 | #endif | 1263 | #endif |
| 1264 | 1264 | ||
| 1265 | ireq = inet_rsk(req); | ||
| 1266 | ireq->loc_addr = daddr; | ||
| 1267 | ireq->rmt_addr = saddr; | ||
| 1268 | ireq->no_srccheck = inet_sk(sk)->transparent; | ||
| 1269 | ireq->opt = tcp_v4_save_options(sk, skb); | ||
| 1270 | |||
| 1271 | dst = inet_csk_route_req(sk, req); | ||
| 1272 | if(!dst) | ||
| 1273 | goto drop_and_free; | ||
| 1274 | |||
| 1275 | tcp_clear_options(&tmp_opt); | 1265 | tcp_clear_options(&tmp_opt); |
| 1276 | tmp_opt.mss_clamp = TCP_MSS_DEFAULT; | 1266 | tmp_opt.mss_clamp = TCP_MSS_DEFAULT; |
| 1277 | tmp_opt.user_mss = tp->rx_opt.user_mss; | 1267 | tmp_opt.user_mss = tp->rx_opt.user_mss; |
| 1278 | tcp_parse_options(skb, &tmp_opt, &hash_location, 0, dst); | 1268 | tcp_parse_options(skb, &tmp_opt, &hash_location, 0); |
| 1279 | 1269 | ||
| 1280 | if (tmp_opt.cookie_plus > 0 && | 1270 | if (tmp_opt.cookie_plus > 0 && |
| 1281 | tmp_opt.saw_tstamp && | 1271 | tmp_opt.saw_tstamp && |
| @@ -1319,8 +1309,14 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
| 1319 | tmp_opt.tstamp_ok = tmp_opt.saw_tstamp; | 1309 | tmp_opt.tstamp_ok = tmp_opt.saw_tstamp; |
| 1320 | tcp_openreq_init(req, &tmp_opt, skb); | 1310 | tcp_openreq_init(req, &tmp_opt, skb); |
| 1321 | 1311 | ||
| 1312 | ireq = inet_rsk(req); | ||
| 1313 | ireq->loc_addr = daddr; | ||
| 1314 | ireq->rmt_addr = saddr; | ||
| 1315 | ireq->no_srccheck = inet_sk(sk)->transparent; | ||
| 1316 | ireq->opt = tcp_v4_save_options(sk, skb); | ||
| 1317 | |||
| 1322 | if (security_inet_conn_request(sk, skb, req)) | 1318 | if (security_inet_conn_request(sk, skb, req)) |
| 1323 | goto drop_and_release; | 1319 | goto drop_and_free; |
| 1324 | 1320 | ||
| 1325 | if (!want_cookie) | 1321 | if (!want_cookie) |
| 1326 | TCP_ECN_create_request(req, tcp_hdr(skb)); | 1322 | TCP_ECN_create_request(req, tcp_hdr(skb)); |
| @@ -1345,6 +1341,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
| 1345 | */ | 1341 | */ |
| 1346 | if (tmp_opt.saw_tstamp && | 1342 | if (tmp_opt.saw_tstamp && |
| 1347 | tcp_death_row.sysctl_tw_recycle && | 1343 | tcp_death_row.sysctl_tw_recycle && |
| 1344 | (dst = inet_csk_route_req(sk, req)) != NULL && | ||
| 1348 | (peer = rt_get_peer((struct rtable *)dst)) != NULL && | 1345 | (peer = rt_get_peer((struct rtable *)dst)) != NULL && |
| 1349 | peer->v4daddr == saddr) { | 1346 | peer->v4daddr == saddr) { |
| 1350 | if ((u32)get_seconds() - peer->tcp_ts_stamp < TCP_PAWS_MSL && | 1347 | if ((u32)get_seconds() - peer->tcp_ts_stamp < TCP_PAWS_MSL && |
| @@ -1464,7 +1461,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
| 1464 | } | 1461 | } |
| 1465 | #endif | 1462 | #endif |
| 1466 | 1463 | ||
| 1467 | __inet_hash_nolisten(newsk); | 1464 | __inet_hash_nolisten(newsk, NULL); |
| 1468 | __inet_inherit_port(sk, newsk); | 1465 | __inet_inherit_port(sk, newsk); |
| 1469 | 1466 | ||
| 1470 | return newsk; | 1467 | return newsk; |
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 87accec8d097..f206ee5dda80 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c | |||
| @@ -95,9 +95,9 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb, | |||
| 95 | struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw); | 95 | struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw); |
| 96 | int paws_reject = 0; | 96 | int paws_reject = 0; |
| 97 | 97 | ||
| 98 | tmp_opt.saw_tstamp = 0; | ||
| 98 | if (th->doff > (sizeof(*th) >> 2) && tcptw->tw_ts_recent_stamp) { | 99 | if (th->doff > (sizeof(*th) >> 2) && tcptw->tw_ts_recent_stamp) { |
| 99 | tmp_opt.tstamp_ok = 1; | 100 | tcp_parse_options(skb, &tmp_opt, &hash_location, 0); |
| 100 | tcp_parse_options(skb, &tmp_opt, &hash_location, 1, NULL); | ||
| 101 | 101 | ||
| 102 | if (tmp_opt.saw_tstamp) { | 102 | if (tmp_opt.saw_tstamp) { |
| 103 | tmp_opt.ts_recent = tcptw->tw_ts_recent; | 103 | tmp_opt.ts_recent = tcptw->tw_ts_recent; |
| @@ -526,9 +526,9 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, | |||
| 526 | __be32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK); | 526 | __be32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK); |
| 527 | int paws_reject = 0; | 527 | int paws_reject = 0; |
| 528 | 528 | ||
| 529 | if ((th->doff > (sizeof(*th) >> 2)) && (req->ts_recent)) { | 529 | tmp_opt.saw_tstamp = 0; |
| 530 | tmp_opt.tstamp_ok = 1; | 530 | if (th->doff > (sizeof(struct tcphdr)>>2)) { |
| 531 | tcp_parse_options(skb, &tmp_opt, &hash_location, 1, NULL); | 531 | tcp_parse_options(skb, &tmp_opt, &hash_location, 0); |
| 532 | 532 | ||
| 533 | if (tmp_opt.saw_tstamp) { | 533 | if (tmp_opt.saw_tstamp) { |
| 534 | tmp_opt.ts_recent = req->ts_recent; | 534 | tmp_opt.ts_recent = req->ts_recent; |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 93316a96d820..383ce237640f 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
| @@ -553,7 +553,6 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb, | |||
| 553 | struct tcp_md5sig_key **md5) { | 553 | struct tcp_md5sig_key **md5) { |
| 554 | struct tcp_sock *tp = tcp_sk(sk); | 554 | struct tcp_sock *tp = tcp_sk(sk); |
| 555 | struct tcp_cookie_values *cvp = tp->cookie_values; | 555 | struct tcp_cookie_values *cvp = tp->cookie_values; |
| 556 | struct dst_entry *dst = __sk_dst_get(sk); | ||
| 557 | unsigned remaining = MAX_TCP_OPTION_SPACE; | 556 | unsigned remaining = MAX_TCP_OPTION_SPACE; |
| 558 | u8 cookie_size = (!tp->rx_opt.cookie_out_never && cvp != NULL) ? | 557 | u8 cookie_size = (!tp->rx_opt.cookie_out_never && cvp != NULL) ? |
| 559 | tcp_cookie_size_check(cvp->cookie_desired) : | 558 | tcp_cookie_size_check(cvp->cookie_desired) : |
| @@ -581,22 +580,18 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb, | |||
| 581 | opts->mss = tcp_advertise_mss(sk); | 580 | opts->mss = tcp_advertise_mss(sk); |
| 582 | remaining -= TCPOLEN_MSS_ALIGNED; | 581 | remaining -= TCPOLEN_MSS_ALIGNED; |
| 583 | 582 | ||
| 584 | if (likely(sysctl_tcp_timestamps && | 583 | if (likely(sysctl_tcp_timestamps && *md5 == NULL)) { |
| 585 | !dst_feature(dst, RTAX_FEATURE_NO_TSTAMP) && | ||
| 586 | *md5 == NULL)) { | ||
| 587 | opts->options |= OPTION_TS; | 584 | opts->options |= OPTION_TS; |
| 588 | opts->tsval = TCP_SKB_CB(skb)->when; | 585 | opts->tsval = TCP_SKB_CB(skb)->when; |
| 589 | opts->tsecr = tp->rx_opt.ts_recent; | 586 | opts->tsecr = tp->rx_opt.ts_recent; |
| 590 | remaining -= TCPOLEN_TSTAMP_ALIGNED; | 587 | remaining -= TCPOLEN_TSTAMP_ALIGNED; |
| 591 | } | 588 | } |
| 592 | if (likely(sysctl_tcp_window_scaling && | 589 | if (likely(sysctl_tcp_window_scaling)) { |
| 593 | !dst_feature(dst, RTAX_FEATURE_NO_WSCALE))) { | ||
| 594 | opts->ws = tp->rx_opt.rcv_wscale; | 590 | opts->ws = tp->rx_opt.rcv_wscale; |
| 595 | opts->options |= OPTION_WSCALE; | 591 | opts->options |= OPTION_WSCALE; |
| 596 | remaining -= TCPOLEN_WSCALE_ALIGNED; | 592 | remaining -= TCPOLEN_WSCALE_ALIGNED; |
| 597 | } | 593 | } |
| 598 | if (likely(sysctl_tcp_sack && | 594 | if (likely(sysctl_tcp_sack)) { |
| 599 | !dst_feature(dst, RTAX_FEATURE_NO_SACK))) { | ||
| 600 | opts->options |= OPTION_SACK_ADVERTISE; | 595 | opts->options |= OPTION_SACK_ADVERTISE; |
| 601 | if (unlikely(!(OPTION_TS & opts->options))) | 596 | if (unlikely(!(OPTION_TS & opts->options))) |
| 602 | remaining -= TCPOLEN_SACKPERM_ALIGNED; | 597 | remaining -= TCPOLEN_SACKPERM_ALIGNED; |
| @@ -2527,9 +2522,7 @@ static void tcp_connect_init(struct sock *sk) | |||
| 2527 | * See tcp_input.c:tcp_rcv_state_process case TCP_SYN_SENT. | 2522 | * See tcp_input.c:tcp_rcv_state_process case TCP_SYN_SENT. |
| 2528 | */ | 2523 | */ |
| 2529 | tp->tcp_header_len = sizeof(struct tcphdr) + | 2524 | tp->tcp_header_len = sizeof(struct tcphdr) + |
| 2530 | (sysctl_tcp_timestamps && | 2525 | (sysctl_tcp_timestamps ? TCPOLEN_TSTAMP_ALIGNED : 0); |
| 2531 | (!dst_feature(dst, RTAX_FEATURE_NO_TSTAMP) ? | ||
| 2532 | TCPOLEN_TSTAMP_ALIGNED : 0)); | ||
| 2533 | 2526 | ||
| 2534 | #ifdef CONFIG_TCP_MD5SIG | 2527 | #ifdef CONFIG_TCP_MD5SIG |
| 2535 | if (tp->af_specific->md5_lookup(sk, sk) != NULL) | 2528 | if (tp->af_specific->md5_lookup(sk, sk) != NULL) |
| @@ -2555,8 +2548,7 @@ static void tcp_connect_init(struct sock *sk) | |||
| 2555 | tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0), | 2548 | tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0), |
| 2556 | &tp->rcv_wnd, | 2549 | &tp->rcv_wnd, |
| 2557 | &tp->window_clamp, | 2550 | &tp->window_clamp, |
| 2558 | (sysctl_tcp_window_scaling && | 2551 | sysctl_tcp_window_scaling, |
| 2559 | !dst_feature(dst, RTAX_FEATURE_NO_WSCALE)), | ||
| 2560 | &rcv_wscale); | 2552 | &rcv_wscale); |
| 2561 | 2553 | ||
| 2562 | tp->rx_opt.rcv_wscale = rcv_wscale; | 2554 | tp->rx_opt.rcv_wscale = rcv_wscale; |
diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c index bb110c5ce1d2..9bc805df95d2 100644 --- a/net/ipv4/tcp_probe.c +++ b/net/ipv4/tcp_probe.c | |||
| @@ -39,9 +39,9 @@ static int port __read_mostly = 0; | |||
| 39 | MODULE_PARM_DESC(port, "Port to match (0=all)"); | 39 | MODULE_PARM_DESC(port, "Port to match (0=all)"); |
| 40 | module_param(port, int, 0); | 40 | module_param(port, int, 0); |
| 41 | 41 | ||
| 42 | static int bufsize __read_mostly = 4096; | 42 | static unsigned int bufsize __read_mostly = 4096; |
| 43 | MODULE_PARM_DESC(bufsize, "Log buffer size in packets (4096)"); | 43 | MODULE_PARM_DESC(bufsize, "Log buffer size in packets (4096)"); |
| 44 | module_param(bufsize, int, 0); | 44 | module_param(bufsize, uint, 0); |
| 45 | 45 | ||
| 46 | static int full __read_mostly; | 46 | static int full __read_mostly; |
| 47 | MODULE_PARM_DESC(full, "Full log (1=every ack packet received, 0=only cwnd changes)"); | 47 | MODULE_PARM_DESC(full, "Full log (1=every ack packet received, 0=only cwnd changes)"); |
| @@ -75,12 +75,12 @@ static struct { | |||
| 75 | 75 | ||
| 76 | static inline int tcp_probe_used(void) | 76 | static inline int tcp_probe_used(void) |
| 77 | { | 77 | { |
| 78 | return (tcp_probe.head - tcp_probe.tail) % bufsize; | 78 | return (tcp_probe.head - tcp_probe.tail) & (bufsize - 1); |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | static inline int tcp_probe_avail(void) | 81 | static inline int tcp_probe_avail(void) |
| 82 | { | 82 | { |
| 83 | return bufsize - tcp_probe_used(); | 83 | return bufsize - tcp_probe_used() - 1; |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | /* | 86 | /* |
| @@ -116,7 +116,7 @@ static int jtcp_rcv_established(struct sock *sk, struct sk_buff *skb, | |||
| 116 | p->ssthresh = tcp_current_ssthresh(sk); | 116 | p->ssthresh = tcp_current_ssthresh(sk); |
| 117 | p->srtt = tp->srtt >> 3; | 117 | p->srtt = tp->srtt >> 3; |
| 118 | 118 | ||
| 119 | tcp_probe.head = (tcp_probe.head + 1) % bufsize; | 119 | tcp_probe.head = (tcp_probe.head + 1) & (bufsize - 1); |
| 120 | } | 120 | } |
| 121 | tcp_probe.lastcwnd = tp->snd_cwnd; | 121 | tcp_probe.lastcwnd = tp->snd_cwnd; |
| 122 | spin_unlock(&tcp_probe.lock); | 122 | spin_unlock(&tcp_probe.lock); |
| @@ -149,7 +149,7 @@ static int tcpprobe_open(struct inode * inode, struct file * file) | |||
| 149 | static int tcpprobe_sprint(char *tbuf, int n) | 149 | static int tcpprobe_sprint(char *tbuf, int n) |
| 150 | { | 150 | { |
| 151 | const struct tcp_log *p | 151 | const struct tcp_log *p |
| 152 | = tcp_probe.log + tcp_probe.tail % bufsize; | 152 | = tcp_probe.log + tcp_probe.tail; |
| 153 | struct timespec tv | 153 | struct timespec tv |
| 154 | = ktime_to_timespec(ktime_sub(p->tstamp, tcp_probe.start)); | 154 | = ktime_to_timespec(ktime_sub(p->tstamp, tcp_probe.start)); |
| 155 | 155 | ||
| @@ -192,7 +192,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf, | |||
| 192 | width = tcpprobe_sprint(tbuf, sizeof(tbuf)); | 192 | width = tcpprobe_sprint(tbuf, sizeof(tbuf)); |
| 193 | 193 | ||
| 194 | if (cnt + width < len) | 194 | if (cnt + width < len) |
| 195 | tcp_probe.tail = (tcp_probe.tail + 1) % bufsize; | 195 | tcp_probe.tail = (tcp_probe.tail + 1) & (bufsize - 1); |
| 196 | 196 | ||
| 197 | spin_unlock_bh(&tcp_probe.lock); | 197 | spin_unlock_bh(&tcp_probe.lock); |
| 198 | 198 | ||
| @@ -222,9 +222,10 @@ static __init int tcpprobe_init(void) | |||
| 222 | init_waitqueue_head(&tcp_probe.wait); | 222 | init_waitqueue_head(&tcp_probe.wait); |
| 223 | spin_lock_init(&tcp_probe.lock); | 223 | spin_lock_init(&tcp_probe.lock); |
| 224 | 224 | ||
| 225 | if (bufsize < 0) | 225 | if (bufsize == 0) |
| 226 | return -EINVAL; | 226 | return -EINVAL; |
| 227 | 227 | ||
| 228 | bufsize = roundup_pow_of_two(bufsize); | ||
| 228 | tcp_probe.log = kcalloc(bufsize, sizeof(struct tcp_log), GFP_KERNEL); | 229 | tcp_probe.log = kcalloc(bufsize, sizeof(struct tcp_log), GFP_KERNEL); |
| 229 | if (!tcp_probe.log) | 230 | if (!tcp_probe.log) |
| 230 | goto err0; | 231 | goto err0; |
| @@ -236,7 +237,7 @@ static __init int tcpprobe_init(void) | |||
| 236 | if (ret) | 237 | if (ret) |
| 237 | goto err1; | 238 | goto err1; |
| 238 | 239 | ||
| 239 | pr_info("TCP probe registered (port=%d)\n", port); | 240 | pr_info("TCP probe registered (port=%d) bufsize=%u\n", port, bufsize); |
| 240 | return 0; | 241 | return 0; |
| 241 | err1: | 242 | err1: |
| 242 | proc_net_remove(&init_net, procname); | 243 | proc_net_remove(&init_net, procname); |
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 8353a538cd4c..8816a20c2597 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c | |||
| @@ -132,6 +132,35 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk) | |||
| 132 | } | 132 | } |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | /* This function calculates a "timeout" which is equivalent to the timeout of a | ||
| 136 | * TCP connection after "boundary" unsucessful, exponentially backed-off | ||
| 137 | * retransmissions with an initial RTO of TCP_RTO_MIN. | ||
| 138 | */ | ||
| 139 | static bool retransmits_timed_out(struct sock *sk, | ||
| 140 | unsigned int boundary) | ||
| 141 | { | ||
| 142 | unsigned int timeout, linear_backoff_thresh; | ||
| 143 | unsigned int start_ts; | ||
| 144 | |||
| 145 | if (!inet_csk(sk)->icsk_retransmits) | ||
| 146 | return false; | ||
| 147 | |||
| 148 | if (unlikely(!tcp_sk(sk)->retrans_stamp)) | ||
| 149 | start_ts = TCP_SKB_CB(tcp_write_queue_head(sk))->when; | ||
| 150 | else | ||
| 151 | start_ts = tcp_sk(sk)->retrans_stamp; | ||
| 152 | |||
| 153 | linear_backoff_thresh = ilog2(TCP_RTO_MAX/TCP_RTO_MIN); | ||
| 154 | |||
| 155 | if (boundary <= linear_backoff_thresh) | ||
| 156 | timeout = ((2 << boundary) - 1) * TCP_RTO_MIN; | ||
| 157 | else | ||
| 158 | timeout = ((2 << linear_backoff_thresh) - 1) * TCP_RTO_MIN + | ||
| 159 | (boundary - linear_backoff_thresh) * TCP_RTO_MAX; | ||
| 160 | |||
| 161 | return (tcp_time_stamp - start_ts) >= timeout; | ||
| 162 | } | ||
| 163 | |||
| 135 | /* A write timeout has occurred. Process the after effects. */ | 164 | /* A write timeout has occurred. Process the after effects. */ |
| 136 | static int tcp_write_timeout(struct sock *sk) | 165 | static int tcp_write_timeout(struct sock *sk) |
| 137 | { | 166 | { |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 1f9534846ca9..f0126fdd7e04 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
| @@ -216,9 +216,8 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum, | |||
| 216 | * force rand to be an odd multiple of UDP_HTABLE_SIZE | 216 | * force rand to be an odd multiple of UDP_HTABLE_SIZE |
| 217 | */ | 217 | */ |
| 218 | rand = (rand | 1) * (udptable->mask + 1); | 218 | rand = (rand | 1) * (udptable->mask + 1); |
| 219 | for (last = first + udptable->mask + 1; | 219 | last = first + udptable->mask + 1; |
| 220 | first != last; | 220 | do { |
| 221 | first++) { | ||
| 222 | hslot = udp_hashslot(udptable, net, first); | 221 | hslot = udp_hashslot(udptable, net, first); |
| 223 | bitmap_zero(bitmap, PORTS_PER_CHAIN); | 222 | bitmap_zero(bitmap, PORTS_PER_CHAIN); |
| 224 | spin_lock_bh(&hslot->lock); | 223 | spin_lock_bh(&hslot->lock); |
| @@ -238,7 +237,7 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum, | |||
| 238 | snum += rand; | 237 | snum += rand; |
| 239 | } while (snum != first); | 238 | } while (snum != first); |
| 240 | spin_unlock_bh(&hslot->lock); | 239 | spin_unlock_bh(&hslot->lock); |
| 241 | } | 240 | } while (++first != last); |
| 242 | goto fail; | 241 | goto fail; |
| 243 | } else { | 242 | } else { |
| 244 | hslot = udp_hashslot(udptable, net, snum); | 243 | hslot = udp_hashslot(udptable, net, snum); |
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index 8c08a28d8f83..67107d63c1cd 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c | |||
| @@ -15,7 +15,6 @@ | |||
| 15 | #include <net/xfrm.h> | 15 | #include <net/xfrm.h> |
| 16 | #include <net/ip.h> | 16 | #include <net/ip.h> |
| 17 | 17 | ||
| 18 | static struct dst_ops xfrm4_dst_ops; | ||
| 19 | static struct xfrm_policy_afinfo xfrm4_policy_afinfo; | 18 | static struct xfrm_policy_afinfo xfrm4_policy_afinfo; |
| 20 | 19 | ||
| 21 | static struct dst_entry *xfrm4_dst_lookup(struct net *net, int tos, | 20 | static struct dst_entry *xfrm4_dst_lookup(struct net *net, int tos, |
| @@ -190,8 +189,10 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) | |||
| 190 | 189 | ||
| 191 | static inline int xfrm4_garbage_collect(struct dst_ops *ops) | 190 | static inline int xfrm4_garbage_collect(struct dst_ops *ops) |
| 192 | { | 191 | { |
| 193 | xfrm4_policy_afinfo.garbage_collect(&init_net); | 192 | struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops); |
| 194 | return (atomic_read(&xfrm4_dst_ops.entries) > xfrm4_dst_ops.gc_thresh*2); | 193 | |
| 194 | xfrm4_policy_afinfo.garbage_collect(net); | ||
| 195 | return (atomic_read(&ops->entries) > ops->gc_thresh * 2); | ||
| 195 | } | 196 | } |
| 196 | 197 | ||
| 197 | static void xfrm4_update_pmtu(struct dst_entry *dst, u32 mtu) | 198 | static void xfrm4_update_pmtu(struct dst_entry *dst, u32 mtu) |
| @@ -268,7 +269,7 @@ static struct xfrm_policy_afinfo xfrm4_policy_afinfo = { | |||
| 268 | static struct ctl_table xfrm4_policy_table[] = { | 269 | static struct ctl_table xfrm4_policy_table[] = { |
| 269 | { | 270 | { |
| 270 | .procname = "xfrm4_gc_thresh", | 271 | .procname = "xfrm4_gc_thresh", |
| 271 | .data = &xfrm4_dst_ops.gc_thresh, | 272 | .data = &init_net.xfrm.xfrm4_dst_ops.gc_thresh, |
| 272 | .maxlen = sizeof(int), | 273 | .maxlen = sizeof(int), |
| 273 | .mode = 0644, | 274 | .mode = 0644, |
| 274 | .proc_handler = proc_dointvec, | 275 | .proc_handler = proc_dointvec, |
| @@ -295,8 +296,6 @@ static void __exit xfrm4_policy_fini(void) | |||
| 295 | 296 | ||
| 296 | void __init xfrm4_init(int rt_max_size) | 297 | void __init xfrm4_init(int rt_max_size) |
| 297 | { | 298 | { |
| 298 | xfrm4_state_init(); | ||
| 299 | xfrm4_policy_init(); | ||
| 300 | /* | 299 | /* |
| 301 | * Select a default value for the gc_thresh based on the main route | 300 | * Select a default value for the gc_thresh based on the main route |
| 302 | * table hash size. It seems to me the worst case scenario is when | 301 | * table hash size. It seems to me the worst case scenario is when |
| @@ -308,6 +307,9 @@ void __init xfrm4_init(int rt_max_size) | |||
| 308 | * and start cleaning when were 1/2 full | 307 | * and start cleaning when were 1/2 full |
| 309 | */ | 308 | */ |
| 310 | xfrm4_dst_ops.gc_thresh = rt_max_size/2; | 309 | xfrm4_dst_ops.gc_thresh = rt_max_size/2; |
| 310 | |||
| 311 | xfrm4_state_init(); | ||
| 312 | xfrm4_policy_init(); | ||
| 311 | #ifdef CONFIG_SYSCTL | 313 | #ifdef CONFIG_SYSCTL |
| 312 | sysctl_hdr = register_net_sysctl_table(&init_net, net_ipv4_ctl_path, | 314 | sysctl_hdr = register_net_sysctl_table(&init_net, net_ipv4_ctl_path, |
| 313 | xfrm4_policy_table); | 315 | xfrm4_policy_table); |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index de7a194a64ab..143791da062c 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
| @@ -502,8 +502,11 @@ static int addrconf_fixup_forwarding(struct ctl_table *table, int *p, int old) | |||
| 502 | if (p == &net->ipv6.devconf_dflt->forwarding) | 502 | if (p == &net->ipv6.devconf_dflt->forwarding) |
| 503 | return 0; | 503 | return 0; |
| 504 | 504 | ||
| 505 | if (!rtnl_trylock()) | 505 | if (!rtnl_trylock()) { |
| 506 | /* Restore the original values before restarting */ | ||
| 507 | *p = old; | ||
| 506 | return restart_syscall(); | 508 | return restart_syscall(); |
| 509 | } | ||
| 507 | 510 | ||
| 508 | if (p == &net->ipv6.devconf_all->forwarding) { | 511 | if (p == &net->ipv6.devconf_all->forwarding) { |
| 509 | __s32 newf = net->ipv6.devconf_all->forwarding; | 512 | __s32 newf = net->ipv6.devconf_all->forwarding; |
| @@ -4028,12 +4031,15 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write, | |||
| 4028 | { | 4031 | { |
| 4029 | int *valp = ctl->data; | 4032 | int *valp = ctl->data; |
| 4030 | int val = *valp; | 4033 | int val = *valp; |
| 4034 | loff_t pos = *ppos; | ||
| 4031 | int ret; | 4035 | int ret; |
| 4032 | 4036 | ||
| 4033 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); | 4037 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 4034 | 4038 | ||
| 4035 | if (write) | 4039 | if (write) |
| 4036 | ret = addrconf_fixup_forwarding(ctl, valp, val); | 4040 | ret = addrconf_fixup_forwarding(ctl, valp, val); |
| 4041 | if (ret) | ||
| 4042 | *ppos = pos; | ||
| 4037 | return ret; | 4043 | return ret; |
| 4038 | } | 4044 | } |
| 4039 | 4045 | ||
| @@ -4075,8 +4081,11 @@ static int addrconf_disable_ipv6(struct ctl_table *table, int *p, int old) | |||
| 4075 | if (p == &net->ipv6.devconf_dflt->disable_ipv6) | 4081 | if (p == &net->ipv6.devconf_dflt->disable_ipv6) |
| 4076 | return 0; | 4082 | return 0; |
| 4077 | 4083 | ||
| 4078 | if (!rtnl_trylock()) | 4084 | if (!rtnl_trylock()) { |
| 4085 | /* Restore the original values before restarting */ | ||
| 4086 | *p = old; | ||
| 4079 | return restart_syscall(); | 4087 | return restart_syscall(); |
| 4088 | } | ||
| 4080 | 4089 | ||
| 4081 | if (p == &net->ipv6.devconf_all->disable_ipv6) { | 4090 | if (p == &net->ipv6.devconf_all->disable_ipv6) { |
| 4082 | __s32 newf = net->ipv6.devconf_all->disable_ipv6; | 4091 | __s32 newf = net->ipv6.devconf_all->disable_ipv6; |
| @@ -4095,12 +4104,15 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write, | |||
| 4095 | { | 4104 | { |
| 4096 | int *valp = ctl->data; | 4105 | int *valp = ctl->data; |
| 4097 | int val = *valp; | 4106 | int val = *valp; |
| 4107 | loff_t pos = *ppos; | ||
| 4098 | int ret; | 4108 | int ret; |
| 4099 | 4109 | ||
| 4100 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); | 4110 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 4101 | 4111 | ||
| 4102 | if (write) | 4112 | if (write) |
| 4103 | ret = addrconf_disable_ipv6(ctl, valp, val); | 4113 | ret = addrconf_disable_ipv6(ctl, valp, val); |
| 4114 | if (ret) | ||
| 4115 | *ppos = pos; | ||
| 4104 | return ret; | 4116 | return ret; |
| 4105 | } | 4117 | } |
| 4106 | 4118 | ||
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c index df159fffe4bc..4bac362b1335 100644 --- a/net/ipv6/exthdrs.c +++ b/net/ipv6/exthdrs.c | |||
| @@ -559,6 +559,11 @@ static inline struct inet6_dev *ipv6_skb_idev(struct sk_buff *skb) | |||
| 559 | return skb_dst(skb) ? ip6_dst_idev(skb_dst(skb)) : __in6_dev_get(skb->dev); | 559 | return skb_dst(skb) ? ip6_dst_idev(skb_dst(skb)) : __in6_dev_get(skb->dev); |
| 560 | } | 560 | } |
| 561 | 561 | ||
| 562 | static inline struct net *ipv6_skb_net(struct sk_buff *skb) | ||
| 563 | { | ||
| 564 | return skb_dst(skb) ? dev_net(skb_dst(skb)->dev) : dev_net(skb->dev); | ||
| 565 | } | ||
| 566 | |||
| 562 | /* Router Alert as of RFC 2711 */ | 567 | /* Router Alert as of RFC 2711 */ |
| 563 | 568 | ||
| 564 | static int ipv6_hop_ra(struct sk_buff *skb, int optoff) | 569 | static int ipv6_hop_ra(struct sk_buff *skb, int optoff) |
| @@ -580,8 +585,8 @@ static int ipv6_hop_ra(struct sk_buff *skb, int optoff) | |||
| 580 | static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff) | 585 | static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff) |
| 581 | { | 586 | { |
| 582 | const unsigned char *nh = skb_network_header(skb); | 587 | const unsigned char *nh = skb_network_header(skb); |
| 588 | struct net *net = ipv6_skb_net(skb); | ||
| 583 | u32 pkt_len; | 589 | u32 pkt_len; |
| 584 | struct net *net = dev_net(skb_dst(skb)->dev); | ||
| 585 | 590 | ||
| 586 | if (nh[optoff + 1] != 4 || (optoff & 3) != 2) { | 591 | if (nh[optoff + 1] != 4 || (optoff & 3) != 2) { |
| 587 | LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n", | 592 | LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n", |
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index c813e294ec0c..633a6c266136 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c | |||
| @@ -22,9 +22,10 @@ | |||
| 22 | #include <net/inet6_hashtables.h> | 22 | #include <net/inet6_hashtables.h> |
| 23 | #include <net/ip.h> | 23 | #include <net/ip.h> |
| 24 | 24 | ||
| 25 | void __inet6_hash(struct sock *sk) | 25 | int __inet6_hash(struct sock *sk, struct inet_timewait_sock *tw) |
| 26 | { | 26 | { |
| 27 | struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; | 27 | struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; |
| 28 | int twrefcnt = 0; | ||
| 28 | 29 | ||
| 29 | WARN_ON(!sk_unhashed(sk)); | 30 | WARN_ON(!sk_unhashed(sk)); |
| 30 | 31 | ||
| @@ -45,10 +46,15 @@ void __inet6_hash(struct sock *sk) | |||
| 45 | lock = inet_ehash_lockp(hashinfo, hash); | 46 | lock = inet_ehash_lockp(hashinfo, hash); |
| 46 | spin_lock(lock); | 47 | spin_lock(lock); |
| 47 | __sk_nulls_add_node_rcu(sk, list); | 48 | __sk_nulls_add_node_rcu(sk, list); |
| 49 | if (tw) { | ||
| 50 | WARN_ON(sk->sk_hash != tw->tw_hash); | ||
| 51 | twrefcnt = inet_twsk_unhash(tw); | ||
| 52 | } | ||
| 48 | spin_unlock(lock); | 53 | spin_unlock(lock); |
| 49 | } | 54 | } |
| 50 | 55 | ||
| 51 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); | 56 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); |
| 57 | return twrefcnt; | ||
| 52 | } | 58 | } |
| 53 | EXPORT_SYMBOL(__inet6_hash); | 59 | EXPORT_SYMBOL(__inet6_hash); |
| 54 | 60 | ||
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index cd48801a8d6f..eb6d09728633 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
| @@ -121,10 +121,9 @@ static int ip6_output2(struct sk_buff *skb) | |||
| 121 | skb->dev = dev; | 121 | skb->dev = dev; |
| 122 | 122 | ||
| 123 | if (ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr)) { | 123 | if (ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr)) { |
| 124 | struct ipv6_pinfo* np = skb->sk ? inet6_sk(skb->sk) : NULL; | ||
| 125 | struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb)); | 124 | struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb)); |
| 126 | 125 | ||
| 127 | if (!(dev->flags & IFF_LOOPBACK) && (!np || np->mc_loop) && | 126 | if (!(dev->flags & IFF_LOOPBACK) && sk_mc_loop(skb->sk) && |
| 128 | ((mroute6_socket(dev_net(dev)) && | 127 | ((mroute6_socket(dev_net(dev)) && |
| 129 | !(IP6CB(skb)->flags & IP6SKB_FORWARDED)) || | 128 | !(IP6CB(skb)->flags & IP6SKB_FORWARDED)) || |
| 130 | ipv6_chk_mcast_addr(dev, &ipv6_hdr(skb)->daddr, | 129 | ipv6_chk_mcast_addr(dev, &ipv6_hdr(skb)->daddr, |
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c index 2f2a5ca2c878..002e6eef9120 100644 --- a/net/ipv6/ipcomp6.c +++ b/net/ipv6/ipcomp6.c | |||
| @@ -154,16 +154,12 @@ static int ipcomp6_init_state(struct xfrm_state *x) | |||
| 154 | if (x->props.mode == XFRM_MODE_TUNNEL) { | 154 | if (x->props.mode == XFRM_MODE_TUNNEL) { |
| 155 | err = ipcomp6_tunnel_attach(x); | 155 | err = ipcomp6_tunnel_attach(x); |
| 156 | if (err) | 156 | if (err) |
| 157 | goto error_tunnel; | 157 | goto out; |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | err = 0; | 160 | err = 0; |
| 161 | out: | 161 | out: |
| 162 | return err; | 162 | return err; |
| 163 | error_tunnel: | ||
| 164 | ipcomp_destroy(x); | ||
| 165 | |||
| 166 | goto out; | ||
| 167 | } | 163 | } |
| 168 | 164 | ||
| 169 | static const struct xfrm_type ipcomp6_type = | 165 | static const struct xfrm_type ipcomp6_type = |
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index 480d7f8c9802..8a7e0f52e177 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c | |||
| @@ -1164,10 +1164,10 @@ static int get_info(struct net *net, void __user *user, int *len, int compat) | |||
| 1164 | if (t && !IS_ERR(t)) { | 1164 | if (t && !IS_ERR(t)) { |
| 1165 | struct ip6t_getinfo info; | 1165 | struct ip6t_getinfo info; |
| 1166 | const struct xt_table_info *private = t->private; | 1166 | const struct xt_table_info *private = t->private; |
| 1167 | |||
| 1168 | #ifdef CONFIG_COMPAT | 1167 | #ifdef CONFIG_COMPAT |
| 1168 | struct xt_table_info tmp; | ||
| 1169 | |||
| 1169 | if (compat) { | 1170 | if (compat) { |
| 1170 | struct xt_table_info tmp; | ||
| 1171 | ret = compat_table_info(private, &tmp); | 1171 | ret = compat_table_info(private, &tmp); |
| 1172 | xt_compat_flush_offsets(AF_INET6); | 1172 | xt_compat_flush_offsets(AF_INET6); |
| 1173 | private = &tmp; | 1173 | private = &tmp; |
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c index 5f2ec208a8c3..0956ebabbff2 100644 --- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <net/ipv6.h> | 20 | #include <net/ipv6.h> |
| 21 | #include <net/inet_frag.h> | 21 | #include <net/inet_frag.h> |
| 22 | 22 | ||
| 23 | #include <linux/netfilter_bridge.h> | ||
| 23 | #include <linux/netfilter_ipv6.h> | 24 | #include <linux/netfilter_ipv6.h> |
| 24 | #include <net/netfilter/nf_conntrack.h> | 25 | #include <net/netfilter/nf_conntrack.h> |
| 25 | #include <net/netfilter/nf_conntrack_helper.h> | 26 | #include <net/netfilter/nf_conntrack_helper.h> |
| @@ -187,6 +188,21 @@ out: | |||
| 187 | return nf_conntrack_confirm(skb); | 188 | return nf_conntrack_confirm(skb); |
| 188 | } | 189 | } |
| 189 | 190 | ||
| 191 | static enum ip6_defrag_users nf_ct6_defrag_user(unsigned int hooknum, | ||
| 192 | struct sk_buff *skb) | ||
| 193 | { | ||
| 194 | #ifdef CONFIG_BRIDGE_NETFILTER | ||
| 195 | if (skb->nf_bridge && | ||
| 196 | skb->nf_bridge->mask & BRNF_NF_BRIDGE_PREROUTING) | ||
| 197 | return IP6_DEFRAG_CONNTRACK_BRIDGE_IN; | ||
| 198 | #endif | ||
| 199 | if (hooknum == NF_INET_PRE_ROUTING) | ||
| 200 | return IP6_DEFRAG_CONNTRACK_IN; | ||
| 201 | else | ||
| 202 | return IP6_DEFRAG_CONNTRACK_OUT; | ||
| 203 | |||
| 204 | } | ||
| 205 | |||
| 190 | static unsigned int ipv6_defrag(unsigned int hooknum, | 206 | static unsigned int ipv6_defrag(unsigned int hooknum, |
| 191 | struct sk_buff *skb, | 207 | struct sk_buff *skb, |
| 192 | const struct net_device *in, | 208 | const struct net_device *in, |
| @@ -199,8 +215,7 @@ static unsigned int ipv6_defrag(unsigned int hooknum, | |||
| 199 | if (skb->nfct) | 215 | if (skb->nfct) |
| 200 | return NF_ACCEPT; | 216 | return NF_ACCEPT; |
| 201 | 217 | ||
| 202 | reasm = nf_ct_frag6_gather(skb); | 218 | reasm = nf_ct_frag6_gather(skb, nf_ct6_defrag_user(hooknum, skb)); |
| 203 | |||
| 204 | /* queued */ | 219 | /* queued */ |
| 205 | if (reasm == NULL) | 220 | if (reasm == NULL) |
| 206 | return NF_STOLEN; | 221 | return NF_STOLEN; |
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index e0b9424fa1b2..624a54832a7c 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c | |||
| @@ -63,6 +63,7 @@ struct nf_ct_frag6_queue | |||
| 63 | struct inet_frag_queue q; | 63 | struct inet_frag_queue q; |
| 64 | 64 | ||
| 65 | __be32 id; /* fragment id */ | 65 | __be32 id; /* fragment id */ |
| 66 | u32 user; | ||
| 66 | struct in6_addr saddr; | 67 | struct in6_addr saddr; |
| 67 | struct in6_addr daddr; | 68 | struct in6_addr daddr; |
| 68 | 69 | ||
| @@ -168,13 +169,14 @@ out: | |||
| 168 | /* Creation primitives. */ | 169 | /* Creation primitives. */ |
| 169 | 170 | ||
| 170 | static __inline__ struct nf_ct_frag6_queue * | 171 | static __inline__ struct nf_ct_frag6_queue * |
| 171 | fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst) | 172 | fq_find(__be32 id, u32 user, struct in6_addr *src, struct in6_addr *dst) |
| 172 | { | 173 | { |
| 173 | struct inet_frag_queue *q; | 174 | struct inet_frag_queue *q; |
| 174 | struct ip6_create_arg arg; | 175 | struct ip6_create_arg arg; |
| 175 | unsigned int hash; | 176 | unsigned int hash; |
| 176 | 177 | ||
| 177 | arg.id = id; | 178 | arg.id = id; |
| 179 | arg.user = user; | ||
| 178 | arg.src = src; | 180 | arg.src = src; |
| 179 | arg.dst = dst; | 181 | arg.dst = dst; |
| 180 | 182 | ||
| @@ -559,7 +561,7 @@ find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff) | |||
| 559 | return 0; | 561 | return 0; |
| 560 | } | 562 | } |
| 561 | 563 | ||
| 562 | struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb) | 564 | struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user) |
| 563 | { | 565 | { |
| 564 | struct sk_buff *clone; | 566 | struct sk_buff *clone; |
| 565 | struct net_device *dev = skb->dev; | 567 | struct net_device *dev = skb->dev; |
| @@ -605,7 +607,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb) | |||
| 605 | if (atomic_read(&nf_init_frags.mem) > nf_init_frags.high_thresh) | 607 | if (atomic_read(&nf_init_frags.mem) > nf_init_frags.high_thresh) |
| 606 | nf_ct_frag6_evictor(); | 608 | nf_ct_frag6_evictor(); |
| 607 | 609 | ||
| 608 | fq = fq_find(fhdr->identification, &hdr->saddr, &hdr->daddr); | 610 | fq = fq_find(fhdr->identification, user, &hdr->saddr, &hdr->daddr); |
| 609 | if (fq == NULL) { | 611 | if (fq == NULL) { |
| 610 | pr_debug("Can't find and can't create new queue\n"); | 612 | pr_debug("Can't find and can't create new queue\n"); |
| 611 | goto ret_orig; | 613 | goto ret_orig; |
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 4d98549a6868..2cddea3bd6be 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
| @@ -72,6 +72,7 @@ struct frag_queue | |||
| 72 | struct inet_frag_queue q; | 72 | struct inet_frag_queue q; |
| 73 | 73 | ||
| 74 | __be32 id; /* fragment id */ | 74 | __be32 id; /* fragment id */ |
| 75 | u32 user; | ||
| 75 | struct in6_addr saddr; | 76 | struct in6_addr saddr; |
| 76 | struct in6_addr daddr; | 77 | struct in6_addr daddr; |
| 77 | 78 | ||
| @@ -141,7 +142,7 @@ int ip6_frag_match(struct inet_frag_queue *q, void *a) | |||
| 141 | struct ip6_create_arg *arg = a; | 142 | struct ip6_create_arg *arg = a; |
| 142 | 143 | ||
| 143 | fq = container_of(q, struct frag_queue, q); | 144 | fq = container_of(q, struct frag_queue, q); |
| 144 | return (fq->id == arg->id && | 145 | return (fq->id == arg->id && fq->user == arg->user && |
| 145 | ipv6_addr_equal(&fq->saddr, arg->src) && | 146 | ipv6_addr_equal(&fq->saddr, arg->src) && |
| 146 | ipv6_addr_equal(&fq->daddr, arg->dst)); | 147 | ipv6_addr_equal(&fq->daddr, arg->dst)); |
| 147 | } | 148 | } |
| @@ -163,6 +164,7 @@ void ip6_frag_init(struct inet_frag_queue *q, void *a) | |||
| 163 | struct ip6_create_arg *arg = a; | 164 | struct ip6_create_arg *arg = a; |
| 164 | 165 | ||
| 165 | fq->id = arg->id; | 166 | fq->id = arg->id; |
| 167 | fq->user = arg->user; | ||
| 166 | ipv6_addr_copy(&fq->saddr, arg->src); | 168 | ipv6_addr_copy(&fq->saddr, arg->src); |
| 167 | ipv6_addr_copy(&fq->daddr, arg->dst); | 169 | ipv6_addr_copy(&fq->daddr, arg->dst); |
| 168 | } | 170 | } |
| @@ -243,6 +245,7 @@ fq_find(struct net *net, __be32 id, struct in6_addr *src, struct in6_addr *dst, | |||
| 243 | unsigned int hash; | 245 | unsigned int hash; |
| 244 | 246 | ||
| 245 | arg.id = id; | 247 | arg.id = id; |
| 248 | arg.user = IP6_DEFRAG_LOCAL_DELIVER; | ||
| 246 | arg.src = src; | 249 | arg.src = src; |
| 247 | arg.dst = dst; | 250 | arg.dst = dst; |
| 248 | 251 | ||
| @@ -705,7 +708,8 @@ static void ip6_frags_ns_sysctl_unregister(struct net *net) | |||
| 705 | 708 | ||
| 706 | table = net->ipv6.sysctl.frags_hdr->ctl_table_arg; | 709 | table = net->ipv6.sysctl.frags_hdr->ctl_table_arg; |
| 707 | unregister_net_sysctl_table(net->ipv6.sysctl.frags_hdr); | 710 | unregister_net_sysctl_table(net->ipv6.sysctl.frags_hdr); |
| 708 | kfree(table); | 711 | if (!net_eq(net, &init_net)) |
| 712 | kfree(table); | ||
| 709 | } | 713 | } |
| 710 | 714 | ||
| 711 | static struct ctl_table_header *ip6_ctl_header; | 715 | static struct ctl_table_header *ip6_ctl_header; |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index db3b27303890..c2bd74c5f8d9 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
| @@ -2630,6 +2630,7 @@ struct ctl_table *ipv6_route_sysctl_init(struct net *net) | |||
| 2630 | table[6].data = &net->ipv6.sysctl.ip6_rt_gc_elasticity; | 2630 | table[6].data = &net->ipv6.sysctl.ip6_rt_gc_elasticity; |
| 2631 | table[7].data = &net->ipv6.sysctl.ip6_rt_mtu_expires; | 2631 | table[7].data = &net->ipv6.sysctl.ip6_rt_mtu_expires; |
| 2632 | table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss; | 2632 | table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss; |
| 2633 | table[9].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval; | ||
| 2633 | } | 2634 | } |
| 2634 | 2635 | ||
| 2635 | return table; | 2636 | return table; |
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c index 5b9af508b8f2..7208a06576c6 100644 --- a/net/ipv6/syncookies.c +++ b/net/ipv6/syncookies.c | |||
| @@ -185,6 +185,13 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) | |||
| 185 | 185 | ||
| 186 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESRECV); | 186 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESRECV); |
| 187 | 187 | ||
| 188 | /* check for timestamp cookie support */ | ||
| 189 | memset(&tcp_opt, 0, sizeof(tcp_opt)); | ||
| 190 | tcp_parse_options(skb, &tcp_opt, &hash_location, 0); | ||
| 191 | |||
| 192 | if (tcp_opt.saw_tstamp) | ||
| 193 | cookie_check_timestamp(&tcp_opt); | ||
| 194 | |||
| 188 | ret = NULL; | 195 | ret = NULL; |
| 189 | req = inet6_reqsk_alloc(&tcp6_request_sock_ops); | 196 | req = inet6_reqsk_alloc(&tcp6_request_sock_ops); |
| 190 | if (!req) | 197 | if (!req) |
| @@ -218,6 +225,12 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) | |||
| 218 | req->expires = 0UL; | 225 | req->expires = 0UL; |
| 219 | req->retrans = 0; | 226 | req->retrans = 0; |
| 220 | ireq->ecn_ok = 0; | 227 | ireq->ecn_ok = 0; |
| 228 | ireq->snd_wscale = tcp_opt.snd_wscale; | ||
| 229 | ireq->rcv_wscale = tcp_opt.rcv_wscale; | ||
| 230 | ireq->sack_ok = tcp_opt.sack_ok; | ||
| 231 | ireq->wscale_ok = tcp_opt.wscale_ok; | ||
| 232 | ireq->tstamp_ok = tcp_opt.saw_tstamp; | ||
| 233 | req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0; | ||
| 221 | treq->rcv_isn = ntohl(th->seq) - 1; | 234 | treq->rcv_isn = ntohl(th->seq) - 1; |
| 222 | treq->snt_isn = cookie; | 235 | treq->snt_isn = cookie; |
| 223 | 236 | ||
| @@ -253,21 +266,6 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) | |||
| 253 | goto out_free; | 266 | goto out_free; |
| 254 | } | 267 | } |
| 255 | 268 | ||
| 256 | /* check for timestamp cookie support */ | ||
| 257 | memset(&tcp_opt, 0, sizeof(tcp_opt)); | ||
| 258 | tcp_parse_options(skb, &tcp_opt, &hash_location, 0, dst); | ||
| 259 | |||
| 260 | if (tcp_opt.saw_tstamp) | ||
| 261 | cookie_check_timestamp(&tcp_opt); | ||
| 262 | |||
| 263 | req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0; | ||
| 264 | |||
| 265 | ireq->snd_wscale = tcp_opt.snd_wscale; | ||
| 266 | ireq->rcv_wscale = tcp_opt.rcv_wscale; | ||
| 267 | ireq->sack_ok = tcp_opt.sack_ok; | ||
| 268 | ireq->wscale_ok = tcp_opt.wscale_ok; | ||
| 269 | ireq->tstamp_ok = tcp_opt.saw_tstamp; | ||
| 270 | |||
| 271 | req->window_clamp = tp->window_clamp ? :dst_metric(dst, RTAX_WINDOW); | 269 | req->window_clamp = tp->window_clamp ? :dst_metric(dst, RTAX_WINDOW); |
| 272 | tcp_select_initial_window(tcp_full_space(sk), req->mss, | 270 | tcp_select_initial_window(tcp_full_space(sk), req->mss, |
| 273 | &req->rcv_wnd, &req->window_clamp, | 271 | &req->rcv_wnd, &req->window_clamp, |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index aadd7cef73b3..febfd595a40d 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
| @@ -96,7 +96,7 @@ static void tcp_v6_hash(struct sock *sk) | |||
| 96 | return; | 96 | return; |
| 97 | } | 97 | } |
| 98 | local_bh_disable(); | 98 | local_bh_disable(); |
| 99 | __inet6_hash(sk); | 99 | __inet6_hash(sk, NULL); |
| 100 | local_bh_enable(); | 100 | local_bh_enable(); |
| 101 | } | 101 | } |
| 102 | } | 102 | } |
| @@ -1169,7 +1169,6 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) | |||
| 1169 | struct inet6_request_sock *treq; | 1169 | struct inet6_request_sock *treq; |
| 1170 | struct ipv6_pinfo *np = inet6_sk(sk); | 1170 | struct ipv6_pinfo *np = inet6_sk(sk); |
| 1171 | struct tcp_sock *tp = tcp_sk(sk); | 1171 | struct tcp_sock *tp = tcp_sk(sk); |
| 1172 | struct dst_entry *dst = __sk_dst_get(sk); | ||
| 1173 | __u32 isn = TCP_SKB_CB(skb)->when; | 1172 | __u32 isn = TCP_SKB_CB(skb)->when; |
| 1174 | #ifdef CONFIG_SYN_COOKIES | 1173 | #ifdef CONFIG_SYN_COOKIES |
| 1175 | int want_cookie = 0; | 1174 | int want_cookie = 0; |
| @@ -1208,7 +1207,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) | |||
| 1208 | tcp_clear_options(&tmp_opt); | 1207 | tcp_clear_options(&tmp_opt); |
| 1209 | tmp_opt.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr); | 1208 | tmp_opt.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr); |
| 1210 | tmp_opt.user_mss = tp->rx_opt.user_mss; | 1209 | tmp_opt.user_mss = tp->rx_opt.user_mss; |
| 1211 | tcp_parse_options(skb, &tmp_opt, &hash_location, 0, dst); | 1210 | tcp_parse_options(skb, &tmp_opt, &hash_location, 0); |
| 1212 | 1211 | ||
| 1213 | if (tmp_opt.cookie_plus > 0 && | 1212 | if (tmp_opt.cookie_plus > 0 && |
| 1214 | tmp_opt.saw_tstamp && | 1213 | tmp_opt.saw_tstamp && |
| @@ -1496,7 +1495,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
| 1496 | } | 1495 | } |
| 1497 | #endif | 1496 | #endif |
| 1498 | 1497 | ||
| 1499 | __inet6_hash(newsk); | 1498 | __inet6_hash(newsk, NULL); |
| 1500 | __inet_inherit_port(sk, newsk); | 1499 | __inet_inherit_port(sk, newsk); |
| 1501 | 1500 | ||
| 1502 | return newsk; | 1501 | return newsk; |
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index 7254e3f899a7..dbdc696f5fc5 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c | |||
| @@ -24,7 +24,6 @@ | |||
| 24 | #include <net/mip6.h> | 24 | #include <net/mip6.h> |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | static struct dst_ops xfrm6_dst_ops; | ||
| 28 | static struct xfrm_policy_afinfo xfrm6_policy_afinfo; | 27 | static struct xfrm_policy_afinfo xfrm6_policy_afinfo; |
| 29 | 28 | ||
| 30 | static struct dst_entry *xfrm6_dst_lookup(struct net *net, int tos, | 29 | static struct dst_entry *xfrm6_dst_lookup(struct net *net, int tos, |
| @@ -224,8 +223,10 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse) | |||
| 224 | 223 | ||
| 225 | static inline int xfrm6_garbage_collect(struct dst_ops *ops) | 224 | static inline int xfrm6_garbage_collect(struct dst_ops *ops) |
| 226 | { | 225 | { |
| 227 | xfrm6_policy_afinfo.garbage_collect(&init_net); | 226 | struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops); |
| 228 | return (atomic_read(&xfrm6_dst_ops.entries) > xfrm6_dst_ops.gc_thresh*2); | 227 | |
| 228 | xfrm6_policy_afinfo.garbage_collect(net); | ||
| 229 | return (atomic_read(&ops->entries) > ops->gc_thresh * 2); | ||
| 229 | } | 230 | } |
| 230 | 231 | ||
| 231 | static void xfrm6_update_pmtu(struct dst_entry *dst, u32 mtu) | 232 | static void xfrm6_update_pmtu(struct dst_entry *dst, u32 mtu) |
| @@ -310,7 +311,7 @@ static void xfrm6_policy_fini(void) | |||
| 310 | static struct ctl_table xfrm6_policy_table[] = { | 311 | static struct ctl_table xfrm6_policy_table[] = { |
| 311 | { | 312 | { |
| 312 | .procname = "xfrm6_gc_thresh", | 313 | .procname = "xfrm6_gc_thresh", |
| 313 | .data = &xfrm6_dst_ops.gc_thresh, | 314 | .data = &init_net.xfrm.xfrm6_dst_ops.gc_thresh, |
| 314 | .maxlen = sizeof(int), | 315 | .maxlen = sizeof(int), |
| 315 | .mode = 0644, | 316 | .mode = 0644, |
| 316 | .proc_handler = proc_dointvec, | 317 | .proc_handler = proc_dointvec, |
| @@ -326,13 +327,6 @@ int __init xfrm6_init(void) | |||
| 326 | int ret; | 327 | int ret; |
| 327 | unsigned int gc_thresh; | 328 | unsigned int gc_thresh; |
| 328 | 329 | ||
| 329 | ret = xfrm6_policy_init(); | ||
| 330 | if (ret) | ||
| 331 | goto out; | ||
| 332 | |||
| 333 | ret = xfrm6_state_init(); | ||
| 334 | if (ret) | ||
| 335 | goto out_policy; | ||
| 336 | /* | 330 | /* |
| 337 | * We need a good default value for the xfrm6 gc threshold. | 331 | * We need a good default value for the xfrm6 gc threshold. |
| 338 | * In ipv4 we set it to the route hash table size * 8, which | 332 | * In ipv4 we set it to the route hash table size * 8, which |
| @@ -346,6 +340,15 @@ int __init xfrm6_init(void) | |||
| 346 | */ | 340 | */ |
| 347 | gc_thresh = FIB6_TABLE_HASHSZ * 8; | 341 | gc_thresh = FIB6_TABLE_HASHSZ * 8; |
| 348 | xfrm6_dst_ops.gc_thresh = (gc_thresh < 1024) ? 1024 : gc_thresh; | 342 | xfrm6_dst_ops.gc_thresh = (gc_thresh < 1024) ? 1024 : gc_thresh; |
| 343 | |||
| 344 | ret = xfrm6_policy_init(); | ||
| 345 | if (ret) | ||
| 346 | goto out; | ||
| 347 | |||
| 348 | ret = xfrm6_state_init(); | ||
| 349 | if (ret) | ||
| 350 | goto out_policy; | ||
| 351 | |||
| 349 | #ifdef CONFIG_SYSCTL | 352 | #ifdef CONFIG_SYSCTL |
| 350 | sysctl_hdr = register_net_sysctl_table(&init_net, net_ipv6_ctl_path, | 353 | sysctl_hdr = register_net_sysctl_table(&init_net, net_ipv6_ctl_path, |
| 351 | xfrm6_policy_table); | 354 | xfrm6_policy_table); |
diff --git a/net/irda/irlap.c b/net/irda/irlap.c index 356e65b1dc42..783c5f367d29 100644 --- a/net/irda/irlap.c +++ b/net/irda/irlap.c | |||
| @@ -450,10 +450,10 @@ void irlap_disconnect_request(struct irlap_cb *self) | |||
| 450 | 450 | ||
| 451 | /* Check if we are in the right state for disconnecting */ | 451 | /* Check if we are in the right state for disconnecting */ |
| 452 | switch (self->state) { | 452 | switch (self->state) { |
| 453 | case LAP_XMIT_P: /* FALLTROUGH */ | 453 | case LAP_XMIT_P: /* FALLTHROUGH */ |
| 454 | case LAP_XMIT_S: /* FALLTROUGH */ | 454 | case LAP_XMIT_S: /* FALLTHROUGH */ |
| 455 | case LAP_CONN: /* FALLTROUGH */ | 455 | case LAP_CONN: /* FALLTHROUGH */ |
| 456 | case LAP_RESET_WAIT: /* FALLTROUGH */ | 456 | case LAP_RESET_WAIT: /* FALLTHROUGH */ |
| 457 | case LAP_RESET_CHECK: | 457 | case LAP_RESET_CHECK: |
| 458 | irlap_do_event(self, DISCONNECT_REQUEST, NULL, NULL); | 458 | irlap_do_event(self, DISCONNECT_REQUEST, NULL, NULL); |
| 459 | break; | 459 | break; |
| @@ -485,9 +485,9 @@ void irlap_disconnect_indication(struct irlap_cb *self, LAP_REASON reason) | |||
| 485 | IRDA_DEBUG(1, "%s(), Sending reset request!\n", __func__); | 485 | IRDA_DEBUG(1, "%s(), Sending reset request!\n", __func__); |
| 486 | irlap_do_event(self, RESET_REQUEST, NULL, NULL); | 486 | irlap_do_event(self, RESET_REQUEST, NULL, NULL); |
| 487 | break; | 487 | break; |
| 488 | case LAP_NO_RESPONSE: /* FALLTROUGH */ | 488 | case LAP_NO_RESPONSE: /* FALLTHROUGH */ |
| 489 | case LAP_DISC_INDICATION: /* FALLTROUGH */ | 489 | case LAP_DISC_INDICATION: /* FALLTHROUGH */ |
| 490 | case LAP_FOUND_NONE: /* FALLTROUGH */ | 490 | case LAP_FOUND_NONE: /* FALLTHROUGH */ |
| 491 | case LAP_MEDIA_BUSY: | 491 | case LAP_MEDIA_BUSY: |
| 492 | irlmp_link_disconnect_indication(self->notify.instance, self, | 492 | irlmp_link_disconnect_indication(self->notify.instance, self, |
| 493 | reason, NULL); | 493 | reason, NULL); |
diff --git a/net/irda/irlap_event.c b/net/irda/irlap_event.c index c5c51959e3ce..94a9884d7146 100644 --- a/net/irda/irlap_event.c +++ b/net/irda/irlap_event.c | |||
| @@ -1741,7 +1741,7 @@ static int irlap_state_reset(struct irlap_cb *self, IRLAP_EVENT event, | |||
| 1741 | * Function irlap_state_xmit_s (event, skb, info) | 1741 | * Function irlap_state_xmit_s (event, skb, info) |
| 1742 | * | 1742 | * |
| 1743 | * XMIT_S, The secondary station has been given the right to transmit, | 1743 | * XMIT_S, The secondary station has been given the right to transmit, |
| 1744 | * and we therefor do not expect to receive any transmissions from other | 1744 | * and we therefore do not expect to receive any transmissions from other |
| 1745 | * stations. | 1745 | * stations. |
| 1746 | */ | 1746 | */ |
| 1747 | static int irlap_state_xmit_s(struct irlap_cb *self, IRLAP_EVENT event, | 1747 | static int irlap_state_xmit_s(struct irlap_cb *self, IRLAP_EVENT event, |
diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c index 7bf5b913828b..0e7d8bde145d 100644 --- a/net/irda/irlmp.c +++ b/net/irda/irlmp.c | |||
| @@ -105,7 +105,7 @@ int __init irlmp_init(void) | |||
| 105 | 105 | ||
| 106 | init_timer(&irlmp->discovery_timer); | 106 | init_timer(&irlmp->discovery_timer); |
| 107 | 107 | ||
| 108 | /* Do discovery every 3 seconds, conditionaly */ | 108 | /* Do discovery every 3 seconds, conditionally */ |
| 109 | if (sysctl_discovery) | 109 | if (sysctl_discovery) |
| 110 | irlmp_start_discovery_timer(irlmp, | 110 | irlmp_start_discovery_timer(irlmp, |
| 111 | sysctl_discovery_timeout*HZ); | 111 | sysctl_discovery_timeout*HZ); |
| @@ -1842,7 +1842,7 @@ LM_REASON irlmp_convert_lap_reason( LAP_REASON lap_reason) | |||
| 1842 | reason = LM_CONNECT_FAILURE; | 1842 | reason = LM_CONNECT_FAILURE; |
| 1843 | break; | 1843 | break; |
| 1844 | default: | 1844 | default: |
| 1845 | IRDA_DEBUG(1, "%s(), Unknow IrLAP disconnect reason %d!\n", | 1845 | IRDA_DEBUG(1, "%s(), Unknown IrLAP disconnect reason %d!\n", |
| 1846 | __func__, lap_reason); | 1846 | __func__, lap_reason); |
| 1847 | reason = LM_LAP_DISCONNECT; | 1847 | reason = LM_LAP_DISCONNECT; |
| 1848 | break; | 1848 | break; |
diff --git a/net/irda/irnet/irnet.h b/net/irda/irnet/irnet.h index b001c361ad30..4300df35d37d 100644 --- a/net/irda/irnet/irnet.h +++ b/net/irda/irnet/irnet.h | |||
| @@ -249,6 +249,7 @@ | |||
| 249 | #include <linux/poll.h> | 249 | #include <linux/poll.h> |
| 250 | #include <linux/capability.h> | 250 | #include <linux/capability.h> |
| 251 | #include <linux/ctype.h> /* isspace() */ | 251 | #include <linux/ctype.h> /* isspace() */ |
| 252 | #include <linux/string.h> /* skip_spaces() */ | ||
| 252 | #include <asm/uaccess.h> | 253 | #include <asm/uaccess.h> |
| 253 | #include <linux/init.h> | 254 | #include <linux/init.h> |
| 254 | 255 | ||
diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c index 7dea882dbb75..6b3602de359a 100644 --- a/net/irda/irnet/irnet_ppp.c +++ b/net/irda/irnet/irnet_ppp.c | |||
| @@ -76,9 +76,8 @@ irnet_ctrl_write(irnet_socket * ap, | |||
| 76 | /* Look at the next command */ | 76 | /* Look at the next command */ |
| 77 | start = next; | 77 | start = next; |
| 78 | 78 | ||
| 79 | /* Scrap whitespaces before the command */ | 79 | /* Scrap whitespaces before the command */ |
| 80 | while(isspace(*start)) | 80 | start = skip_spaces(start); |
| 81 | start++; | ||
| 82 | 81 | ||
| 83 | /* ',' is our command separator */ | 82 | /* ',' is our command separator */ |
| 84 | next = strchr(start, ','); | 83 | next = strchr(start, ','); |
| @@ -133,8 +132,7 @@ irnet_ctrl_write(irnet_socket * ap, | |||
| 133 | char * endp; | 132 | char * endp; |
| 134 | 133 | ||
| 135 | /* Scrap whitespaces before the command */ | 134 | /* Scrap whitespaces before the command */ |
| 136 | while(isspace(*begp)) | 135 | begp = skip_spaces(begp); |
| 137 | begp++; | ||
| 138 | 136 | ||
| 139 | /* Convert argument to a number (last arg is the base) */ | 137 | /* Convert argument to a number (last arg is the base) */ |
| 140 | addr = simple_strtoul(begp, &endp, 16); | 138 | addr = simple_strtoul(begp, &endp, 16); |
| @@ -700,15 +698,18 @@ dev_irnet_ioctl( | |||
| 700 | 698 | ||
| 701 | /* Query PPP channel and unit number */ | 699 | /* Query PPP channel and unit number */ |
| 702 | case PPPIOCGCHAN: | 700 | case PPPIOCGCHAN: |
| 701 | lock_kernel(); | ||
| 703 | if(ap->ppp_open && !put_user(ppp_channel_index(&ap->chan), | 702 | if(ap->ppp_open && !put_user(ppp_channel_index(&ap->chan), |
| 704 | (int __user *)argp)) | 703 | (int __user *)argp)) |
| 705 | err = 0; | 704 | err = 0; |
| 705 | unlock_kernel(); | ||
| 706 | break; | 706 | break; |
| 707 | case PPPIOCGUNIT: | 707 | case PPPIOCGUNIT: |
| 708 | lock_kernel(); | 708 | lock_kernel(); |
| 709 | if(ap->ppp_open && !put_user(ppp_unit_number(&ap->chan), | 709 | if(ap->ppp_open && !put_user(ppp_unit_number(&ap->chan), |
| 710 | (int __user *)argp)) | 710 | (int __user *)argp)) |
| 711 | err = 0; | 711 | err = 0; |
| 712 | unlock_kernel(); | ||
| 712 | break; | 713 | break; |
| 713 | 714 | ||
| 714 | /* All these ioctls can be passed both directly and from ppp_generic, | 715 | /* All these ioctls can be passed both directly and from ppp_generic, |
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index 1e428863574f..c18286a2167b 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c | |||
| @@ -221,7 +221,7 @@ static int afiucv_pm_restore_thaw(struct device *dev) | |||
| 221 | return 0; | 221 | return 0; |
| 222 | } | 222 | } |
| 223 | 223 | ||
| 224 | static struct dev_pm_ops afiucv_pm_ops = { | 224 | static const struct dev_pm_ops afiucv_pm_ops = { |
| 225 | .prepare = afiucv_pm_prepare, | 225 | .prepare = afiucv_pm_prepare, |
| 226 | .complete = afiucv_pm_complete, | 226 | .complete = afiucv_pm_complete, |
| 227 | .freeze = afiucv_pm_freeze, | 227 | .freeze = afiucv_pm_freeze, |
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c index 3b1f5f5f8de7..fd8b28361a64 100644 --- a/net/iucv/iucv.c +++ b/net/iucv/iucv.c | |||
| @@ -93,7 +93,7 @@ static int iucv_pm_freeze(struct device *); | |||
| 93 | static int iucv_pm_thaw(struct device *); | 93 | static int iucv_pm_thaw(struct device *); |
| 94 | static int iucv_pm_restore(struct device *); | 94 | static int iucv_pm_restore(struct device *); |
| 95 | 95 | ||
| 96 | static struct dev_pm_ops iucv_pm_ops = { | 96 | static const struct dev_pm_ops iucv_pm_ops = { |
| 97 | .prepare = iucv_pm_prepare, | 97 | .prepare = iucv_pm_prepare, |
| 98 | .complete = iucv_pm_complete, | 98 | .complete = iucv_pm_complete, |
| 99 | .freeze = iucv_pm_freeze, | 99 | .freeze = iucv_pm_freeze, |
diff --git a/net/key/af_key.c b/net/key/af_key.c index 84209fbbeb17..539f43bc97db 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
| @@ -1193,6 +1193,7 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net, | |||
| 1193 | x->aalg->alg_key_len = key->sadb_key_bits; | 1193 | x->aalg->alg_key_len = key->sadb_key_bits; |
| 1194 | memcpy(x->aalg->alg_key, key+1, keysize); | 1194 | memcpy(x->aalg->alg_key, key+1, keysize); |
| 1195 | } | 1195 | } |
| 1196 | x->aalg->alg_trunc_len = a->uinfo.auth.icv_truncbits; | ||
| 1196 | x->props.aalgo = sa->sadb_sa_auth; | 1197 | x->props.aalgo = sa->sadb_sa_auth; |
| 1197 | /* x->algo.flags = sa->sadb_sa_flags; */ | 1198 | /* x->algo.flags = sa->sadb_sa_flags; */ |
| 1198 | } | 1199 | } |
| @@ -3793,9 +3794,9 @@ static struct pernet_operations pfkey_net_ops = { | |||
| 3793 | 3794 | ||
| 3794 | static void __exit ipsec_pfkey_exit(void) | 3795 | static void __exit ipsec_pfkey_exit(void) |
| 3795 | { | 3796 | { |
| 3796 | unregister_pernet_subsys(&pfkey_net_ops); | ||
| 3797 | xfrm_unregister_km(&pfkeyv2_mgr); | 3797 | xfrm_unregister_km(&pfkeyv2_mgr); |
| 3798 | sock_unregister(PF_KEY); | 3798 | sock_unregister(PF_KEY); |
| 3799 | unregister_pernet_subsys(&pfkey_net_ops); | ||
| 3799 | proto_unregister(&key_proto); | 3800 | proto_unregister(&key_proto); |
| 3800 | } | 3801 | } |
| 3801 | 3802 | ||
| @@ -3806,21 +3807,22 @@ static int __init ipsec_pfkey_init(void) | |||
| 3806 | if (err != 0) | 3807 | if (err != 0) |
| 3807 | goto out; | 3808 | goto out; |
| 3808 | 3809 | ||
| 3809 | err = sock_register(&pfkey_family_ops); | 3810 | err = register_pernet_subsys(&pfkey_net_ops); |
| 3810 | if (err != 0) | 3811 | if (err != 0) |
| 3811 | goto out_unregister_key_proto; | 3812 | goto out_unregister_key_proto; |
| 3813 | err = sock_register(&pfkey_family_ops); | ||
| 3814 | if (err != 0) | ||
| 3815 | goto out_unregister_pernet; | ||
| 3812 | err = xfrm_register_km(&pfkeyv2_mgr); | 3816 | err = xfrm_register_km(&pfkeyv2_mgr); |
| 3813 | if (err != 0) | 3817 | if (err != 0) |
| 3814 | goto out_sock_unregister; | 3818 | goto out_sock_unregister; |
| 3815 | err = register_pernet_subsys(&pfkey_net_ops); | ||
| 3816 | if (err != 0) | ||
| 3817 | goto out_xfrm_unregister_km; | ||
| 3818 | out: | 3819 | out: |
| 3819 | return err; | 3820 | return err; |
| 3820 | out_xfrm_unregister_km: | 3821 | |
| 3821 | xfrm_unregister_km(&pfkeyv2_mgr); | ||
| 3822 | out_sock_unregister: | 3822 | out_sock_unregister: |
| 3823 | sock_unregister(PF_KEY); | 3823 | sock_unregister(PF_KEY); |
| 3824 | out_unregister_pernet: | ||
| 3825 | unregister_pernet_subsys(&pfkey_net_ops); | ||
| 3824 | out_unregister_key_proto: | 3826 | out_unregister_key_proto: |
| 3825 | proto_unregister(&key_proto); | 3827 | proto_unregister(&key_proto); |
| 3826 | goto out; | 3828 | goto out; |
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 93ee1fd5c08d..9ae1a4760b58 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
| @@ -354,7 +354,8 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) | |||
| 354 | sinfo->rx_packets = sta->rx_packets; | 354 | sinfo->rx_packets = sta->rx_packets; |
| 355 | sinfo->tx_packets = sta->tx_packets; | 355 | sinfo->tx_packets = sta->tx_packets; |
| 356 | 356 | ||
| 357 | if (sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) { | 357 | if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) || |
| 358 | (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) { | ||
| 358 | sinfo->filled |= STATION_INFO_SIGNAL; | 359 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 359 | sinfo->signal = (s8)sta->last_signal; | 360 | sinfo->signal = (s8)sta->last_signal; |
| 360 | } | 361 | } |
| @@ -1330,6 +1331,9 @@ static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, | |||
| 1330 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1331 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 1331 | struct ieee80211_conf *conf = &local->hw.conf; | 1332 | struct ieee80211_conf *conf = &local->hw.conf; |
| 1332 | 1333 | ||
| 1334 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | ||
| 1335 | return -EOPNOTSUPP; | ||
| 1336 | |||
| 1333 | if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS)) | 1337 | if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS)) |
| 1334 | return -EOPNOTSUPP; | 1338 | return -EOPNOTSUPP; |
| 1335 | 1339 | ||
diff --git a/net/mac80211/driver-trace.h b/net/mac80211/driver-trace.h index ee94ea0c67e9..da8497ef7063 100644 --- a/net/mac80211/driver-trace.h +++ b/net/mac80211/driver-trace.h | |||
| @@ -680,7 +680,7 @@ TRACE_EVENT(drv_ampdu_action, | |||
| 680 | __entry->ret = ret; | 680 | __entry->ret = ret; |
| 681 | __entry->action = action; | 681 | __entry->action = action; |
| 682 | __entry->tid = tid; | 682 | __entry->tid = tid; |
| 683 | __entry->ssn = *ssn; | 683 | __entry->ssn = ssn ? *ssn : 0; |
| 684 | ), | 684 | ), |
| 685 | 685 | ||
| 686 | TP_printk( | 686 | TP_printk( |
diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c index 3787455fb696..d7dcee680728 100644 --- a/net/mac80211/ht.c +++ b/net/mac80211/ht.c | |||
| @@ -34,9 +34,28 @@ void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_supported_band *sband, | |||
| 34 | 34 | ||
| 35 | ht_cap->ht_supported = true; | 35 | ht_cap->ht_supported = true; |
| 36 | 36 | ||
| 37 | ht_cap->cap = le16_to_cpu(ht_cap_ie->cap_info) & sband->ht_cap.cap; | 37 | /* |
| 38 | ht_cap->cap &= ~IEEE80211_HT_CAP_SM_PS; | 38 | * The bits listed in this expression should be |
| 39 | ht_cap->cap |= sband->ht_cap.cap & IEEE80211_HT_CAP_SM_PS; | 39 | * the same for the peer and us, if the station |
| 40 | * advertises more then we can't use those thus | ||
| 41 | * we mask them out. | ||
| 42 | */ | ||
| 43 | ht_cap->cap = le16_to_cpu(ht_cap_ie->cap_info) & | ||
| 44 | (sband->ht_cap.cap | | ||
| 45 | ~(IEEE80211_HT_CAP_LDPC_CODING | | ||
| 46 | IEEE80211_HT_CAP_SUP_WIDTH_20_40 | | ||
| 47 | IEEE80211_HT_CAP_GRN_FLD | | ||
| 48 | IEEE80211_HT_CAP_SGI_20 | | ||
| 49 | IEEE80211_HT_CAP_SGI_40 | | ||
| 50 | IEEE80211_HT_CAP_DSSSCCK40)); | ||
| 51 | /* | ||
| 52 | * The STBC bits are asymmetric -- if we don't have | ||
| 53 | * TX then mask out the peer's RX and vice versa. | ||
| 54 | */ | ||
| 55 | if (!(sband->ht_cap.cap & IEEE80211_HT_CAP_TX_STBC)) | ||
| 56 | ht_cap->cap &= ~IEEE80211_HT_CAP_RX_STBC; | ||
| 57 | if (!(sband->ht_cap.cap & IEEE80211_HT_CAP_RX_STBC)) | ||
| 58 | ht_cap->cap &= ~IEEE80211_HT_CAP_TX_STBC; | ||
| 40 | 59 | ||
| 41 | ampdu_info = ht_cap_ie->ampdu_params_info; | 60 | ampdu_info = ht_cap_ie->ampdu_params_info; |
| 42 | ht_cap->ampdu_factor = | 61 | ht_cap->ampdu_factor = |
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 10d13856f86c..22f0c2aa7a89 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c | |||
| @@ -382,6 +382,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
| 382 | struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, | 382 | struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, |
| 383 | u8 *bssid,u8 *addr, u32 supp_rates) | 383 | u8 *bssid,u8 *addr, u32 supp_rates) |
| 384 | { | 384 | { |
| 385 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; | ||
| 385 | struct ieee80211_local *local = sdata->local; | 386 | struct ieee80211_local *local = sdata->local; |
| 386 | struct sta_info *sta; | 387 | struct sta_info *sta; |
| 387 | int band = local->hw.conf.channel->band; | 388 | int band = local->hw.conf.channel->band; |
| @@ -397,6 +398,9 @@ struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, | |||
| 397 | return NULL; | 398 | return NULL; |
| 398 | } | 399 | } |
| 399 | 400 | ||
| 401 | if (ifibss->state == IEEE80211_IBSS_MLME_SEARCH) | ||
| 402 | return NULL; | ||
| 403 | |||
| 400 | if (compare_ether_addr(bssid, sdata->u.ibss.bssid)) | 404 | if (compare_ether_addr(bssid, sdata->u.ibss.bssid)) |
| 401 | return NULL; | 405 | return NULL; |
| 402 | 406 | ||
| @@ -643,7 +647,7 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, | |||
| 643 | } | 647 | } |
| 644 | if (pos[1] != 0 && | 648 | if (pos[1] != 0 && |
| 645 | (pos[1] != ifibss->ssid_len || | 649 | (pos[1] != ifibss->ssid_len || |
| 646 | !memcmp(pos + 2, ifibss->ssid, ifibss->ssid_len))) { | 650 | memcmp(pos + 2, ifibss->ssid, ifibss->ssid_len))) { |
| 647 | /* Ignore ProbeReq for foreign SSID */ | 651 | /* Ignore ProbeReq for foreign SSID */ |
| 648 | return; | 652 | return; |
| 649 | } | 653 | } |
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 419f186cfcf0..91dc8636d644 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
| @@ -746,6 +746,7 @@ struct ieee80211_local { | |||
| 746 | unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */ | 746 | unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */ |
| 747 | 747 | ||
| 748 | bool pspolling; | 748 | bool pspolling; |
| 749 | bool scan_ps_enabled; | ||
| 749 | /* | 750 | /* |
| 750 | * PS can only be enabled when we have exactly one managed | 751 | * PS can only be enabled when we have exactly one managed |
| 751 | * interface (and monitors) in PS, this then points there. | 752 | * interface (and monitors) in PS, this then points there. |
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 80c16f6e2af6..32abae3ce32a 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c | |||
| @@ -15,12 +15,14 @@ | |||
| 15 | #include <linux/netdevice.h> | 15 | #include <linux/netdevice.h> |
| 16 | #include <linux/rtnetlink.h> | 16 | #include <linux/rtnetlink.h> |
| 17 | #include <net/mac80211.h> | 17 | #include <net/mac80211.h> |
| 18 | #include <net/ieee80211_radiotap.h> | ||
| 18 | #include "ieee80211_i.h" | 19 | #include "ieee80211_i.h" |
| 19 | #include "sta_info.h" | 20 | #include "sta_info.h" |
| 20 | #include "debugfs_netdev.h" | 21 | #include "debugfs_netdev.h" |
| 21 | #include "mesh.h" | 22 | #include "mesh.h" |
| 22 | #include "led.h" | 23 | #include "led.h" |
| 23 | #include "driver-ops.h" | 24 | #include "driver-ops.h" |
| 25 | #include "wme.h" | ||
| 24 | 26 | ||
| 25 | /** | 27 | /** |
| 26 | * DOC: Interface list locking | 28 | * DOC: Interface list locking |
| @@ -314,7 +316,7 @@ static int ieee80211_open(struct net_device *dev) | |||
| 314 | if (sdata->vif.type == NL80211_IFTYPE_STATION) | 316 | if (sdata->vif.type == NL80211_IFTYPE_STATION) |
| 315 | ieee80211_queue_work(&local->hw, &sdata->u.mgd.work); | 317 | ieee80211_queue_work(&local->hw, &sdata->u.mgd.work); |
| 316 | 318 | ||
| 317 | netif_start_queue(dev); | 319 | netif_tx_start_all_queues(dev); |
| 318 | 320 | ||
| 319 | return 0; | 321 | return 0; |
| 320 | err_del_interface: | 322 | err_del_interface: |
| @@ -343,7 +345,7 @@ static int ieee80211_stop(struct net_device *dev) | |||
| 343 | /* | 345 | /* |
| 344 | * Stop TX on this interface first. | 346 | * Stop TX on this interface first. |
| 345 | */ | 347 | */ |
| 346 | netif_stop_queue(dev); | 348 | netif_tx_stop_all_queues(dev); |
| 347 | 349 | ||
| 348 | /* | 350 | /* |
| 349 | * Now delete all active aggregation sessions. | 351 | * Now delete all active aggregation sessions. |
| @@ -644,6 +646,12 @@ static void ieee80211_teardown_sdata(struct net_device *dev) | |||
| 644 | WARN_ON(flushed); | 646 | WARN_ON(flushed); |
| 645 | } | 647 | } |
| 646 | 648 | ||
| 649 | static u16 ieee80211_netdev_select_queue(struct net_device *dev, | ||
| 650 | struct sk_buff *skb) | ||
| 651 | { | ||
| 652 | return ieee80211_select_queue(IEEE80211_DEV_TO_SUB_IF(dev), skb); | ||
| 653 | } | ||
| 654 | |||
| 647 | static const struct net_device_ops ieee80211_dataif_ops = { | 655 | static const struct net_device_ops ieee80211_dataif_ops = { |
| 648 | .ndo_open = ieee80211_open, | 656 | .ndo_open = ieee80211_open, |
| 649 | .ndo_stop = ieee80211_stop, | 657 | .ndo_stop = ieee80211_stop, |
| @@ -652,8 +660,38 @@ static const struct net_device_ops ieee80211_dataif_ops = { | |||
| 652 | .ndo_set_multicast_list = ieee80211_set_multicast_list, | 660 | .ndo_set_multicast_list = ieee80211_set_multicast_list, |
| 653 | .ndo_change_mtu = ieee80211_change_mtu, | 661 | .ndo_change_mtu = ieee80211_change_mtu, |
| 654 | .ndo_set_mac_address = eth_mac_addr, | 662 | .ndo_set_mac_address = eth_mac_addr, |
| 663 | .ndo_select_queue = ieee80211_netdev_select_queue, | ||
| 655 | }; | 664 | }; |
| 656 | 665 | ||
| 666 | static u16 ieee80211_monitor_select_queue(struct net_device *dev, | ||
| 667 | struct sk_buff *skb) | ||
| 668 | { | ||
| 669 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
| 670 | struct ieee80211_local *local = sdata->local; | ||
| 671 | struct ieee80211_hdr *hdr; | ||
| 672 | struct ieee80211_radiotap_header *rtap = (void *)skb->data; | ||
| 673 | u8 *p; | ||
| 674 | |||
| 675 | if (local->hw.queues < 4) | ||
| 676 | return 0; | ||
| 677 | |||
| 678 | if (skb->len < 4 || | ||
| 679 | skb->len < le16_to_cpu(rtap->it_len) + 2 /* frame control */) | ||
| 680 | return 0; /* doesn't matter, frame will be dropped */ | ||
| 681 | |||
| 682 | hdr = (void *)((u8 *)skb->data + le16_to_cpu(rtap->it_len)); | ||
| 683 | |||
| 684 | if (!ieee80211_is_data_qos(hdr->frame_control)) { | ||
| 685 | skb->priority = 7; | ||
| 686 | return ieee802_1d_to_ac[skb->priority]; | ||
| 687 | } | ||
| 688 | |||
| 689 | p = ieee80211_get_qos_ctl(hdr); | ||
| 690 | skb->priority = *p & IEEE80211_QOS_CTL_TAG1D_MASK; | ||
| 691 | |||
| 692 | return ieee80211_downgrade_queue(local, skb); | ||
| 693 | } | ||
| 694 | |||
| 657 | static const struct net_device_ops ieee80211_monitorif_ops = { | 695 | static const struct net_device_ops ieee80211_monitorif_ops = { |
| 658 | .ndo_open = ieee80211_open, | 696 | .ndo_open = ieee80211_open, |
| 659 | .ndo_stop = ieee80211_stop, | 697 | .ndo_stop = ieee80211_stop, |
| @@ -662,6 +700,7 @@ static const struct net_device_ops ieee80211_monitorif_ops = { | |||
| 662 | .ndo_set_multicast_list = ieee80211_set_multicast_list, | 700 | .ndo_set_multicast_list = ieee80211_set_multicast_list, |
| 663 | .ndo_change_mtu = ieee80211_change_mtu, | 701 | .ndo_change_mtu = ieee80211_change_mtu, |
| 664 | .ndo_set_mac_address = eth_mac_addr, | 702 | .ndo_set_mac_address = eth_mac_addr, |
| 703 | .ndo_select_queue = ieee80211_monitor_select_queue, | ||
| 665 | }; | 704 | }; |
| 666 | 705 | ||
| 667 | static void ieee80211_if_setup(struct net_device *dev) | 706 | static void ieee80211_if_setup(struct net_device *dev) |
| @@ -768,8 +807,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, | |||
| 768 | 807 | ||
| 769 | ASSERT_RTNL(); | 808 | ASSERT_RTNL(); |
| 770 | 809 | ||
| 771 | ndev = alloc_netdev(sizeof(*sdata) + local->hw.vif_data_size, | 810 | ndev = alloc_netdev_mq(sizeof(*sdata) + local->hw.vif_data_size, |
| 772 | name, ieee80211_if_setup); | 811 | name, ieee80211_if_setup, local->hw.queues); |
| 773 | if (!ndev) | 812 | if (!ndev) |
| 774 | return -ENOMEM; | 813 | return -ENOMEM; |
| 775 | dev_net_set(ndev, wiphy_net(local->hw.wiphy)); | 814 | dev_net_set(ndev, wiphy_net(local->hw.wiphy)); |
diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 8116d1a96a4a..0d2d94881f1f 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c | |||
| @@ -515,6 +515,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
| 515 | * and we need some headroom for passing the frame to monitor | 515 | * and we need some headroom for passing the frame to monitor |
| 516 | * interfaces, but never both at the same time. | 516 | * interfaces, but never both at the same time. |
| 517 | */ | 517 | */ |
| 518 | BUILD_BUG_ON(IEEE80211_TX_STATUS_HEADROOM != | ||
| 519 | sizeof(struct ieee80211_tx_status_rtap_hdr)); | ||
| 518 | local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom, | 520 | local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom, |
| 519 | sizeof(struct ieee80211_tx_status_rtap_hdr)); | 521 | sizeof(struct ieee80211_tx_status_rtap_hdr)); |
| 520 | 522 | ||
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index c0fe46493f71..6a4331429598 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
| @@ -427,7 +427,7 @@ int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr, | |||
| 427 | char *addr5, char *addr6) | 427 | char *addr5, char *addr6) |
| 428 | { | 428 | { |
| 429 | int aelen = 0; | 429 | int aelen = 0; |
| 430 | memset(meshhdr, 0, sizeof(meshhdr)); | 430 | memset(meshhdr, 0, sizeof(*meshhdr)); |
| 431 | meshhdr->ttl = sdata->u.mesh.mshcfg.dot11MeshTTL; | 431 | meshhdr->ttl = sdata->u.mesh.mshcfg.dot11MeshTTL; |
| 432 | put_unaligned(cpu_to_le32(sdata->u.mesh.mesh_seqnum), &meshhdr->seqnum); | 432 | put_unaligned(cpu_to_le32(sdata->u.mesh.mesh_seqnum), &meshhdr->seqnum); |
| 433 | sdata->u.mesh.mesh_seqnum++; | 433 | sdata->u.mesh.mesh_seqnum++; |
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h index 31e102541869..85562c59d7d6 100644 --- a/net/mac80211/mesh.h +++ b/net/mac80211/mesh.h | |||
| @@ -188,8 +188,9 @@ struct mesh_rmc { | |||
| 188 | */ | 188 | */ |
| 189 | #define MESH_PREQ_MIN_INT 10 | 189 | #define MESH_PREQ_MIN_INT 10 |
| 190 | #define MESH_DIAM_TRAVERSAL_TIME 50 | 190 | #define MESH_DIAM_TRAVERSAL_TIME 50 |
| 191 | /* Paths will be refreshed if they are closer than PATH_REFRESH_TIME to their | 191 | /* A path will be refreshed if it is used PATH_REFRESH_TIME milliseconds before |
| 192 | * expiration | 192 | * timing out. This way it will remain ACTIVE and no data frames will be |
| 193 | * unnecesarily held in the pending queue. | ||
| 193 | */ | 194 | */ |
| 194 | #define MESH_PATH_REFRESH_TIME 1000 | 195 | #define MESH_PATH_REFRESH_TIME 1000 |
| 195 | #define MESH_MIN_DISCOVERY_TIMEOUT (2 * MESH_DIAM_TRAVERSAL_TIME) | 196 | #define MESH_MIN_DISCOVERY_TIMEOUT (2 * MESH_DIAM_TRAVERSAL_TIME) |
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 833b2f3670c5..d28acb6b1f81 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c | |||
| @@ -937,7 +937,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb, | |||
| 937 | 937 | ||
| 938 | if (mpath->flags & MESH_PATH_ACTIVE) { | 938 | if (mpath->flags & MESH_PATH_ACTIVE) { |
| 939 | if (time_after(jiffies, | 939 | if (time_after(jiffies, |
| 940 | mpath->exp_time + | 940 | mpath->exp_time - |
| 941 | msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) && | 941 | msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) && |
| 942 | !memcmp(sdata->dev->dev_addr, hdr->addr4, ETH_ALEN) && | 942 | !memcmp(sdata->dev->dev_addr, hdr->addr4, ETH_ALEN) && |
| 943 | !(mpath->flags & MESH_PATH_RESOLVING) && | 943 | !(mpath->flags & MESH_PATH_RESOLVING) && |
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index a8da23905c70..0192cfdacae4 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c | |||
| @@ -244,7 +244,7 @@ struct mesh_path *mesh_path_lookup_by_idx(int idx, struct ieee80211_sub_if_data | |||
| 244 | * @addr: destination address of the path (ETH_ALEN length) | 244 | * @addr: destination address of the path (ETH_ALEN length) |
| 245 | * @sdata: local subif | 245 | * @sdata: local subif |
| 246 | * | 246 | * |
| 247 | * Returns: 0 on sucess | 247 | * Returns: 0 on success |
| 248 | * | 248 | * |
| 249 | * State: the initial state of the new path is set to 0 | 249 | * State: the initial state of the new path is set to 0 |
| 250 | */ | 250 | */ |
| @@ -532,7 +532,7 @@ static void mesh_path_node_reclaim(struct rcu_head *rp) | |||
| 532 | * @addr: dst address (ETH_ALEN length) | 532 | * @addr: dst address (ETH_ALEN length) |
| 533 | * @sdata: local subif | 533 | * @sdata: local subif |
| 534 | * | 534 | * |
| 535 | * Returns: 0 if succesful | 535 | * Returns: 0 if successful |
| 536 | */ | 536 | */ |
| 537 | int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata) | 537 | int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata) |
| 538 | { | 538 | { |
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 6dc7b5ad9a41..05a18f43e1bf 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
| @@ -915,6 +915,14 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, | |||
| 915 | sdata->u.mgd.flags &= ~(IEEE80211_STA_CONNECTION_POLL | | 915 | sdata->u.mgd.flags &= ~(IEEE80211_STA_CONNECTION_POLL | |
| 916 | IEEE80211_STA_BEACON_POLL); | 916 | IEEE80211_STA_BEACON_POLL); |
| 917 | 917 | ||
| 918 | /* | ||
| 919 | * Always handle WMM once after association regardless | ||
| 920 | * of the first value the AP uses. Setting -1 here has | ||
| 921 | * that effect because the AP values is an unsigned | ||
| 922 | * 4-bit value. | ||
| 923 | */ | ||
| 924 | sdata->u.mgd.wmm_last_param_set = -1; | ||
| 925 | |||
| 918 | ieee80211_led_assoc(local, 1); | 926 | ieee80211_led_assoc(local, 1); |
| 919 | 927 | ||
| 920 | sdata->vif.bss_conf.assoc = 1; | 928 | sdata->vif.bss_conf.assoc = 1; |
| @@ -934,7 +942,7 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, | |||
| 934 | ieee80211_recalc_ps(local, -1); | 942 | ieee80211_recalc_ps(local, -1); |
| 935 | mutex_unlock(&local->iflist_mtx); | 943 | mutex_unlock(&local->iflist_mtx); |
| 936 | 944 | ||
| 937 | netif_start_queue(sdata->dev); | 945 | netif_tx_start_all_queues(sdata->dev); |
| 938 | netif_carrier_on(sdata->dev); | 946 | netif_carrier_on(sdata->dev); |
| 939 | } | 947 | } |
| 940 | 948 | ||
| @@ -1066,7 +1074,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
| 1066 | * time -- we don't want the scan code to enable queues. | 1074 | * time -- we don't want the scan code to enable queues. |
| 1067 | */ | 1075 | */ |
| 1068 | 1076 | ||
| 1069 | netif_stop_queue(sdata->dev); | 1077 | netif_tx_stop_all_queues(sdata->dev); |
| 1070 | netif_carrier_off(sdata->dev); | 1078 | netif_carrier_off(sdata->dev); |
| 1071 | 1079 | ||
| 1072 | rcu_read_lock(); | 1080 | rcu_read_lock(); |
| @@ -1083,8 +1091,6 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
| 1083 | 1091 | ||
| 1084 | ieee80211_set_wmm_default(sdata); | 1092 | ieee80211_set_wmm_default(sdata); |
| 1085 | 1093 | ||
| 1086 | ieee80211_recalc_idle(local); | ||
| 1087 | |||
| 1088 | /* channel(_type) changes are handled by ieee80211_hw_config */ | 1094 | /* channel(_type) changes are handled by ieee80211_hw_config */ |
| 1089 | local->oper_channel_type = NL80211_CHAN_NO_HT; | 1095 | local->oper_channel_type = NL80211_CHAN_NO_HT; |
| 1090 | 1096 | ||
| @@ -1370,6 +1376,7 @@ ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, | |||
| 1370 | 1376 | ||
| 1371 | if (!wk) { | 1377 | if (!wk) { |
| 1372 | ieee80211_set_disassoc(sdata, true); | 1378 | ieee80211_set_disassoc(sdata, true); |
| 1379 | ieee80211_recalc_idle(sdata->local); | ||
| 1373 | } else { | 1380 | } else { |
| 1374 | list_del(&wk->list); | 1381 | list_del(&wk->list); |
| 1375 | kfree(wk); | 1382 | kfree(wk); |
| @@ -1403,6 +1410,7 @@ ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata, | |||
| 1403 | sdata->dev->name, mgmt->sa, reason_code); | 1410 | sdata->dev->name, mgmt->sa, reason_code); |
| 1404 | 1411 | ||
| 1405 | ieee80211_set_disassoc(sdata, false); | 1412 | ieee80211_set_disassoc(sdata, false); |
| 1413 | ieee80211_recalc_idle(sdata->local); | ||
| 1406 | return RX_MGMT_CFG80211_DISASSOC; | 1414 | return RX_MGMT_CFG80211_DISASSOC; |
| 1407 | } | 1415 | } |
| 1408 | 1416 | ||
| @@ -1955,7 +1963,9 @@ static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, | |||
| 1955 | rma = ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len); | 1963 | rma = ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len); |
| 1956 | break; | 1964 | break; |
| 1957 | case IEEE80211_STYPE_ACTION: | 1965 | case IEEE80211_STYPE_ACTION: |
| 1958 | /* XXX: differentiate, can only happen for CSA now! */ | 1966 | if (mgmt->u.action.category != WLAN_CATEGORY_SPECTRUM_MGMT) |
| 1967 | break; | ||
| 1968 | |||
| 1959 | ieee80211_sta_process_chanswitch(sdata, | 1969 | ieee80211_sta_process_chanswitch(sdata, |
| 1960 | &mgmt->u.action.u.chan_switch.sw_elem, | 1970 | &mgmt->u.action.u.chan_switch.sw_elem, |
| 1961 | ifmgd->associated); | 1971 | ifmgd->associated); |
| @@ -2117,6 +2127,7 @@ static void ieee80211_sta_work(struct work_struct *work) | |||
| 2117 | " after %dms, disconnecting.\n", | 2127 | " after %dms, disconnecting.\n", |
| 2118 | bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ); | 2128 | bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ); |
| 2119 | ieee80211_set_disassoc(sdata, true); | 2129 | ieee80211_set_disassoc(sdata, true); |
| 2130 | ieee80211_recalc_idle(local); | ||
| 2120 | mutex_unlock(&ifmgd->mtx); | 2131 | mutex_unlock(&ifmgd->mtx); |
| 2121 | /* | 2132 | /* |
| 2122 | * must be outside lock due to cfg80211, | 2133 | * must be outside lock due to cfg80211, |
| @@ -2560,6 +2571,8 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, | |||
| 2560 | IEEE80211_STYPE_DEAUTH, req->reason_code, | 2571 | IEEE80211_STYPE_DEAUTH, req->reason_code, |
| 2561 | cookie); | 2572 | cookie); |
| 2562 | 2573 | ||
| 2574 | ieee80211_recalc_idle(sdata->local); | ||
| 2575 | |||
| 2563 | return 0; | 2576 | return 0; |
| 2564 | } | 2577 | } |
| 2565 | 2578 | ||
| @@ -2592,5 +2605,8 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, | |||
| 2592 | ieee80211_send_deauth_disassoc(sdata, req->bss->bssid, | 2605 | ieee80211_send_deauth_disassoc(sdata, req->bss->bssid, |
| 2593 | IEEE80211_STYPE_DISASSOC, req->reason_code, | 2606 | IEEE80211_STYPE_DISASSOC, req->reason_code, |
| 2594 | cookie); | 2607 | cookie); |
| 2608 | |||
| 2609 | ieee80211_recalc_idle(sdata->local); | ||
| 2610 | |||
| 2595 | return 0; | 2611 | return 0; |
| 2596 | } | 2612 | } |
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c index b9007f80cb92..12a2bff7dcdb 100644 --- a/net/mac80211/rate.c +++ b/net/mac80211/rate.c | |||
| @@ -245,6 +245,9 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, | |||
| 245 | info->control.rates[i].count = 1; | 245 | info->control.rates[i].count = 1; |
| 246 | } | 246 | } |
| 247 | 247 | ||
| 248 | if (sdata->local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) | ||
| 249 | return; | ||
| 250 | |||
| 248 | if (sta && sdata->force_unicast_rateidx > -1) { | 251 | if (sta && sdata->force_unicast_rateidx > -1) { |
| 249 | info->control.rates[0].idx = sdata->force_unicast_rateidx; | 252 | info->control.rates[0].idx = sdata->force_unicast_rateidx; |
| 250 | } else { | 253 | } else { |
diff --git a/net/mac80211/rc80211_pid_algo.c b/net/mac80211/rc80211_pid_algo.c index 699d3ed869c4..29bc4c516238 100644 --- a/net/mac80211/rc80211_pid_algo.c +++ b/net/mac80211/rc80211_pid_algo.c | |||
| @@ -190,7 +190,7 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo, | |||
| 190 | rate_control_pid_normalize(pinfo, sband->n_bitrates); | 190 | rate_control_pid_normalize(pinfo, sband->n_bitrates); |
| 191 | 191 | ||
| 192 | /* Compute the proportional, integral and derivative errors. */ | 192 | /* Compute the proportional, integral and derivative errors. */ |
| 193 | err_prop = (pinfo->target << RC_PID_ARITH_SHIFT) - pf; | 193 | err_prop = (pinfo->target - pf) << RC_PID_ARITH_SHIFT; |
| 194 | 194 | ||
| 195 | err_avg = spinfo->err_avg_sc >> pinfo->smoothing_shift; | 195 | err_avg = spinfo->err_avg_sc >> pinfo->smoothing_shift; |
| 196 | spinfo->err_avg_sc = spinfo->err_avg_sc - err_avg + err_prop; | 196 | spinfo->err_avg_sc = spinfo->err_avg_sc - err_avg + err_prop; |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index f237df408378..82a30c1bf3ab 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
| @@ -1712,7 +1712,6 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
| 1712 | mpp_path_add(proxied_addr, mpp_addr, sdata); | 1712 | mpp_path_add(proxied_addr, mpp_addr, sdata); |
| 1713 | } else { | 1713 | } else { |
| 1714 | spin_lock_bh(&mppath->state_lock); | 1714 | spin_lock_bh(&mppath->state_lock); |
| 1715 | mppath->exp_time = jiffies; | ||
| 1716 | if (compare_ether_addr(mppath->mpp, mpp_addr) != 0) | 1715 | if (compare_ether_addr(mppath->mpp, mpp_addr) != 0) |
| 1717 | memcpy(mppath->mpp, mpp_addr, ETH_ALEN); | 1716 | memcpy(mppath->mpp, mpp_addr, ETH_ALEN); |
| 1718 | spin_unlock_bh(&mppath->state_lock); | 1717 | spin_unlock_bh(&mppath->state_lock); |
| @@ -1747,7 +1746,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
| 1747 | memset(info, 0, sizeof(*info)); | 1746 | memset(info, 0, sizeof(*info)); |
| 1748 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; | 1747 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; |
| 1749 | info->control.vif = &rx->sdata->vif; | 1748 | info->control.vif = &rx->sdata->vif; |
| 1750 | ieee80211_select_queue(local, fwd_skb); | 1749 | skb_set_queue_mapping(skb, |
| 1750 | ieee80211_select_queue(rx->sdata, fwd_skb)); | ||
| 1751 | ieee80211_set_qos_hdr(local, skb); | ||
| 1751 | if (is_multicast_ether_addr(fwd_hdr->addr1)) | 1752 | if (is_multicast_ether_addr(fwd_hdr->addr1)) |
| 1752 | IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh, | 1753 | IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh, |
| 1753 | fwded_mcast); | 1754 | fwded_mcast); |
| @@ -2014,6 +2015,10 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | |||
| 2014 | } | 2015 | } |
| 2015 | break; | 2016 | break; |
| 2016 | default: | 2017 | default: |
| 2018 | /* do not process rejected action frames */ | ||
| 2019 | if (mgmt->u.action.category & 0x80) | ||
| 2020 | return RX_DROP_MONITOR; | ||
| 2021 | |||
| 2017 | return RX_CONTINUE; | 2022 | return RX_CONTINUE; |
| 2018 | } | 2023 | } |
| 2019 | 2024 | ||
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index 4cf387c944bf..bc17cf7d68db 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c | |||
| @@ -227,7 +227,8 @@ static bool ieee80211_prep_hw_scan(struct ieee80211_local *local) | |||
| 227 | static void ieee80211_scan_ps_enable(struct ieee80211_sub_if_data *sdata) | 227 | static void ieee80211_scan_ps_enable(struct ieee80211_sub_if_data *sdata) |
| 228 | { | 228 | { |
| 229 | struct ieee80211_local *local = sdata->local; | 229 | struct ieee80211_local *local = sdata->local; |
| 230 | bool ps = false; | 230 | |
| 231 | local->scan_ps_enabled = false; | ||
| 231 | 232 | ||
| 232 | /* FIXME: what to do when local->pspolling is true? */ | 233 | /* FIXME: what to do when local->pspolling is true? */ |
| 233 | 234 | ||
| @@ -235,12 +236,13 @@ static void ieee80211_scan_ps_enable(struct ieee80211_sub_if_data *sdata) | |||
| 235 | cancel_work_sync(&local->dynamic_ps_enable_work); | 236 | cancel_work_sync(&local->dynamic_ps_enable_work); |
| 236 | 237 | ||
| 237 | if (local->hw.conf.flags & IEEE80211_CONF_PS) { | 238 | if (local->hw.conf.flags & IEEE80211_CONF_PS) { |
| 238 | ps = true; | 239 | local->scan_ps_enabled = true; |
| 239 | local->hw.conf.flags &= ~IEEE80211_CONF_PS; | 240 | local->hw.conf.flags &= ~IEEE80211_CONF_PS; |
| 240 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); | 241 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); |
| 241 | } | 242 | } |
| 242 | 243 | ||
| 243 | if (!ps || !(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)) | 244 | if (!(local->scan_ps_enabled) || |
| 245 | !(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)) | ||
| 244 | /* | 246 | /* |
| 245 | * If power save was enabled, no need to send a nullfunc | 247 | * If power save was enabled, no need to send a nullfunc |
| 246 | * frame because AP knows that we are sleeping. But if the | 248 | * frame because AP knows that we are sleeping. But if the |
| @@ -261,7 +263,7 @@ static void ieee80211_scan_ps_disable(struct ieee80211_sub_if_data *sdata) | |||
| 261 | 263 | ||
| 262 | if (!local->ps_sdata) | 264 | if (!local->ps_sdata) |
| 263 | ieee80211_send_nullfunc(local, sdata, 0); | 265 | ieee80211_send_nullfunc(local, sdata, 0); |
| 264 | else { | 266 | else if (local->scan_ps_enabled) { |
| 265 | /* | 267 | /* |
| 266 | * In !IEEE80211_HW_PS_NULLFUNC_STACK case the hardware | 268 | * In !IEEE80211_HW_PS_NULLFUNC_STACK case the hardware |
| 267 | * will send a nullfunc frame with the powersave bit set | 269 | * will send a nullfunc frame with the powersave bit set |
| @@ -277,6 +279,16 @@ static void ieee80211_scan_ps_disable(struct ieee80211_sub_if_data *sdata) | |||
| 277 | */ | 279 | */ |
| 278 | local->hw.conf.flags |= IEEE80211_CONF_PS; | 280 | local->hw.conf.flags |= IEEE80211_CONF_PS; |
| 279 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); | 281 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); |
| 282 | } else if (local->hw.conf.dynamic_ps_timeout > 0) { | ||
| 283 | /* | ||
| 284 | * If IEEE80211_CONF_PS was not set and the dynamic_ps_timer | ||
| 285 | * had been running before leaving the operating channel, | ||
| 286 | * restart the timer now and send a nullfunc frame to inform | ||
| 287 | * the AP that we are awake. | ||
| 288 | */ | ||
| 289 | ieee80211_send_nullfunc(local, sdata, 0); | ||
| 290 | mod_timer(&local->dynamic_ps_timer, jiffies + | ||
| 291 | msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); | ||
| 280 | } | 292 | } |
| 281 | } | 293 | } |
| 282 | 294 | ||
| @@ -341,10 +353,10 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) | |||
| 341 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | 353 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { |
| 342 | if (sdata->u.mgd.associated) { | 354 | if (sdata->u.mgd.associated) { |
| 343 | ieee80211_scan_ps_disable(sdata); | 355 | ieee80211_scan_ps_disable(sdata); |
| 344 | netif_wake_queue(sdata->dev); | 356 | netif_tx_wake_all_queues(sdata->dev); |
| 345 | } | 357 | } |
| 346 | } else | 358 | } else |
| 347 | netif_wake_queue(sdata->dev); | 359 | netif_tx_wake_all_queues(sdata->dev); |
| 348 | 360 | ||
| 349 | /* re-enable beaconing */ | 361 | /* re-enable beaconing */ |
| 350 | if (sdata->vif.type == NL80211_IFTYPE_AP || | 362 | if (sdata->vif.type == NL80211_IFTYPE_AP || |
| @@ -399,7 +411,7 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local) | |||
| 399 | * are handled in the scan state machine | 411 | * are handled in the scan state machine |
| 400 | */ | 412 | */ |
| 401 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | 413 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
| 402 | netif_stop_queue(sdata->dev); | 414 | netif_tx_stop_all_queues(sdata->dev); |
| 403 | } | 415 | } |
| 404 | mutex_unlock(&local->iflist_mtx); | 416 | mutex_unlock(&local->iflist_mtx); |
| 405 | 417 | ||
| @@ -427,6 +439,16 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, | |||
| 427 | if (local->scan_req) | 439 | if (local->scan_req) |
| 428 | return -EBUSY; | 440 | return -EBUSY; |
| 429 | 441 | ||
| 442 | if (req != local->int_scan_req && | ||
| 443 | sdata->vif.type == NL80211_IFTYPE_STATION && | ||
| 444 | !list_empty(&ifmgd->work_list)) { | ||
| 445 | /* actually wait for the work it's doing to finish/time out */ | ||
| 446 | set_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request); | ||
| 447 | local->scan_req = req; | ||
| 448 | local->scan_sdata = sdata; | ||
| 449 | return 0; | ||
| 450 | } | ||
| 451 | |||
| 430 | if (local->ops->hw_scan) { | 452 | if (local->ops->hw_scan) { |
| 431 | u8 *ies; | 453 | u8 *ies; |
| 432 | 454 | ||
| @@ -451,14 +473,6 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, | |||
| 451 | local->scan_req = req; | 473 | local->scan_req = req; |
| 452 | local->scan_sdata = sdata; | 474 | local->scan_sdata = sdata; |
| 453 | 475 | ||
| 454 | if (req != local->int_scan_req && | ||
| 455 | sdata->vif.type == NL80211_IFTYPE_STATION && | ||
| 456 | !list_empty(&ifmgd->work_list)) { | ||
| 457 | /* actually wait for the work it's doing to finish/time out */ | ||
| 458 | set_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request); | ||
| 459 | return 0; | ||
| 460 | } | ||
| 461 | |||
| 462 | if (local->ops->hw_scan) | 476 | if (local->ops->hw_scan) |
| 463 | __set_bit(SCAN_HW_SCANNING, &local->scanning); | 477 | __set_bit(SCAN_HW_SCANNING, &local->scanning); |
| 464 | else | 478 | else |
| @@ -563,7 +577,7 @@ static void ieee80211_scan_state_leave_oper_channel(struct ieee80211_local *loca | |||
| 563 | continue; | 577 | continue; |
| 564 | 578 | ||
| 565 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | 579 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { |
| 566 | netif_stop_queue(sdata->dev); | 580 | netif_tx_stop_all_queues(sdata->dev); |
| 567 | if (sdata->u.mgd.associated) | 581 | if (sdata->u.mgd.associated) |
| 568 | ieee80211_scan_ps_enable(sdata); | 582 | ieee80211_scan_ps_enable(sdata); |
| 569 | } | 583 | } |
| @@ -598,7 +612,7 @@ static void ieee80211_scan_state_enter_oper_channel(struct ieee80211_local *loca | |||
| 598 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | 612 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { |
| 599 | if (sdata->u.mgd.associated) | 613 | if (sdata->u.mgd.associated) |
| 600 | ieee80211_scan_ps_disable(sdata); | 614 | ieee80211_scan_ps_disable(sdata); |
| 601 | netif_wake_queue(sdata->dev); | 615 | netif_tx_wake_all_queues(sdata->dev); |
| 602 | } | 616 | } |
| 603 | } | 617 | } |
| 604 | mutex_unlock(&local->iflist_mtx); | 618 | mutex_unlock(&local->iflist_mtx); |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 8834cc93c716..ac210b586702 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
| @@ -1419,6 +1419,10 @@ static bool need_dynamic_ps(struct ieee80211_local *local) | |||
| 1419 | if (!local->ps_sdata) | 1419 | if (!local->ps_sdata) |
| 1420 | return false; | 1420 | return false; |
| 1421 | 1421 | ||
| 1422 | /* No point if we're going to suspend */ | ||
| 1423 | if (local->quiescing) | ||
| 1424 | return false; | ||
| 1425 | |||
| 1422 | return true; | 1426 | return true; |
| 1423 | } | 1427 | } |
| 1424 | 1428 | ||
| @@ -1508,7 +1512,7 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, | |||
| 1508 | return; | 1512 | return; |
| 1509 | } | 1513 | } |
| 1510 | 1514 | ||
| 1511 | ieee80211_select_queue(local, skb); | 1515 | ieee80211_set_qos_hdr(local, skb); |
| 1512 | ieee80211_tx(sdata, skb, false); | 1516 | ieee80211_tx(sdata, skb, false); |
| 1513 | rcu_read_unlock(); | 1517 | rcu_read_unlock(); |
| 1514 | } | 1518 | } |
| @@ -2287,6 +2291,9 @@ void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) | |||
| 2287 | skb_set_network_header(skb, 0); | 2291 | skb_set_network_header(skb, 0); |
| 2288 | skb_set_transport_header(skb, 0); | 2292 | skb_set_transport_header(skb, 0); |
| 2289 | 2293 | ||
| 2294 | /* send all internal mgmt frames on VO */ | ||
| 2295 | skb_set_queue_mapping(skb, 0); | ||
| 2296 | |||
| 2290 | /* | 2297 | /* |
| 2291 | * The other path calling ieee80211_xmit is from the tasklet, | 2298 | * The other path calling ieee80211_xmit is from the tasklet, |
| 2292 | * and while we can handle concurrent transmissions locking | 2299 | * and while we can handle concurrent transmissions locking |
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index d09f78bb2442..3848140313f5 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
| @@ -269,6 +269,7 @@ static void __ieee80211_wake_queue(struct ieee80211_hw *hw, int queue, | |||
| 269 | enum queue_stop_reason reason) | 269 | enum queue_stop_reason reason) |
| 270 | { | 270 | { |
| 271 | struct ieee80211_local *local = hw_to_local(hw); | 271 | struct ieee80211_local *local = hw_to_local(hw); |
| 272 | struct ieee80211_sub_if_data *sdata; | ||
| 272 | 273 | ||
| 273 | if (WARN_ON(queue >= hw->queues)) | 274 | if (WARN_ON(queue >= hw->queues)) |
| 274 | return; | 275 | return; |
| @@ -281,6 +282,11 @@ static void __ieee80211_wake_queue(struct ieee80211_hw *hw, int queue, | |||
| 281 | 282 | ||
| 282 | if (!skb_queue_empty(&local->pending[queue])) | 283 | if (!skb_queue_empty(&local->pending[queue])) |
| 283 | tasklet_schedule(&local->tx_pending_tasklet); | 284 | tasklet_schedule(&local->tx_pending_tasklet); |
| 285 | |||
| 286 | rcu_read_lock(); | ||
| 287 | list_for_each_entry_rcu(sdata, &local->interfaces, list) | ||
| 288 | netif_tx_wake_queue(netdev_get_tx_queue(sdata->dev, queue)); | ||
| 289 | rcu_read_unlock(); | ||
| 284 | } | 290 | } |
| 285 | 291 | ||
| 286 | void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue, | 292 | void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue, |
| @@ -305,11 +311,17 @@ static void __ieee80211_stop_queue(struct ieee80211_hw *hw, int queue, | |||
| 305 | enum queue_stop_reason reason) | 311 | enum queue_stop_reason reason) |
| 306 | { | 312 | { |
| 307 | struct ieee80211_local *local = hw_to_local(hw); | 313 | struct ieee80211_local *local = hw_to_local(hw); |
| 314 | struct ieee80211_sub_if_data *sdata; | ||
| 308 | 315 | ||
| 309 | if (WARN_ON(queue >= hw->queues)) | 316 | if (WARN_ON(queue >= hw->queues)) |
| 310 | return; | 317 | return; |
| 311 | 318 | ||
| 312 | __set_bit(reason, &local->queue_stop_reasons[queue]); | 319 | __set_bit(reason, &local->queue_stop_reasons[queue]); |
| 320 | |||
| 321 | rcu_read_lock(); | ||
| 322 | list_for_each_entry_rcu(sdata, &local->interfaces, list) | ||
| 323 | netif_tx_stop_queue(netdev_get_tx_queue(sdata->dev, queue)); | ||
| 324 | rcu_read_unlock(); | ||
| 313 | } | 325 | } |
| 314 | 326 | ||
| 315 | void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue, | 327 | void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue, |
| @@ -579,7 +591,7 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, | |||
| 579 | if (elen > left) | 591 | if (elen > left) |
| 580 | break; | 592 | break; |
| 581 | 593 | ||
| 582 | if (calc_crc && id < 64 && (filter & BIT(id))) | 594 | if (calc_crc && id < 64 && (filter & (1ULL << id))) |
| 583 | crc = crc32_be(crc, pos - 2, elen + 2); | 595 | crc = crc32_be(crc, pos - 2, elen + 2); |
| 584 | 596 | ||
| 585 | switch (id) { | 597 | switch (id) { |
| @@ -1039,7 +1051,19 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
| 1039 | 1051 | ||
| 1040 | /* restart hardware */ | 1052 | /* restart hardware */ |
| 1041 | if (local->open_count) { | 1053 | if (local->open_count) { |
| 1054 | /* | ||
| 1055 | * Upon resume hardware can sometimes be goofy due to | ||
| 1056 | * various platform / driver / bus issues, so restarting | ||
| 1057 | * the device may at times not work immediately. Propagate | ||
| 1058 | * the error. | ||
| 1059 | */ | ||
| 1042 | res = drv_start(local); | 1060 | res = drv_start(local); |
| 1061 | if (res) { | ||
| 1062 | WARN(local->suspended, "Harware became unavailable " | ||
| 1063 | "upon resume. This is could be a software issue" | ||
| 1064 | "prior to suspend or a harware issue\n"); | ||
| 1065 | return res; | ||
| 1066 | } | ||
| 1043 | 1067 | ||
| 1044 | ieee80211_led_radio(local, true); | 1068 | ieee80211_led_radio(local, true); |
| 1045 | } | 1069 | } |
diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c index b19b7696f3a2..79d887dae738 100644 --- a/net/mac80211/wme.c +++ b/net/mac80211/wme.c | |||
| @@ -44,22 +44,69 @@ static int wme_downgrade_ac(struct sk_buff *skb) | |||
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | /* Indicate which queue to use. */ | 47 | /* Indicate which queue to use. */ |
| 48 | static u16 classify80211(struct ieee80211_local *local, struct sk_buff *skb) | 48 | u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata, |
| 49 | struct sk_buff *skb) | ||
| 49 | { | 50 | { |
| 50 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 51 | struct ieee80211_local *local = sdata->local; |
| 52 | struct sta_info *sta = NULL; | ||
| 53 | u32 sta_flags = 0; | ||
| 54 | const u8 *ra = NULL; | ||
| 55 | bool qos = false; | ||
| 51 | 56 | ||
| 52 | if (!ieee80211_is_data(hdr->frame_control)) { | 57 | if (local->hw.queues < 4 || skb->len < 6) { |
| 53 | /* management frames go on AC_VO queue, but are sent | 58 | skb->priority = 0; /* required for correct WPA/11i MIC */ |
| 54 | * without QoS control fields */ | 59 | return min_t(u16, local->hw.queues - 1, |
| 55 | return 0; | 60 | ieee802_1d_to_ac[skb->priority]); |
| 61 | } | ||
| 62 | |||
| 63 | rcu_read_lock(); | ||
| 64 | switch (sdata->vif.type) { | ||
| 65 | case NL80211_IFTYPE_AP_VLAN: | ||
| 66 | rcu_read_lock(); | ||
| 67 | sta = rcu_dereference(sdata->u.vlan.sta); | ||
| 68 | if (sta) | ||
| 69 | sta_flags = get_sta_flags(sta); | ||
| 70 | rcu_read_unlock(); | ||
| 71 | if (sta) | ||
| 72 | break; | ||
| 73 | case NL80211_IFTYPE_AP: | ||
| 74 | ra = skb->data; | ||
| 75 | break; | ||
| 76 | case NL80211_IFTYPE_WDS: | ||
| 77 | ra = sdata->u.wds.remote_addr; | ||
| 78 | break; | ||
| 79 | #ifdef CONFIG_MAC80211_MESH | ||
| 80 | case NL80211_IFTYPE_MESH_POINT: | ||
| 81 | /* | ||
| 82 | * XXX: This is clearly broken ... but already was before, | ||
| 83 | * because ieee80211_fill_mesh_addresses() would clear A1 | ||
| 84 | * except for multicast addresses. | ||
| 85 | */ | ||
| 86 | break; | ||
| 87 | #endif | ||
| 88 | case NL80211_IFTYPE_STATION: | ||
| 89 | ra = sdata->u.mgd.bssid; | ||
| 90 | break; | ||
| 91 | case NL80211_IFTYPE_ADHOC: | ||
| 92 | ra = skb->data; | ||
| 93 | break; | ||
| 94 | default: | ||
| 95 | break; | ||
| 56 | } | 96 | } |
| 57 | 97 | ||
| 58 | if (0 /* injected */) { | 98 | if (!sta && ra && !is_multicast_ether_addr(ra)) { |
| 59 | /* use AC from radiotap */ | 99 | sta = sta_info_get(local, ra); |
| 100 | if (sta) | ||
| 101 | sta_flags = get_sta_flags(sta); | ||
| 60 | } | 102 | } |
| 61 | 103 | ||
| 62 | if (!ieee80211_is_data_qos(hdr->frame_control)) { | 104 | if (sta_flags & WLAN_STA_WME) |
| 105 | qos = true; | ||
| 106 | |||
| 107 | rcu_read_unlock(); | ||
| 108 | |||
| 109 | if (!qos) { | ||
| 63 | skb->priority = 0; /* required for correct WPA/11i MIC */ | 110 | skb->priority = 0; /* required for correct WPA/11i MIC */ |
| 64 | return ieee802_1d_to_ac[skb->priority]; | 111 | return ieee802_1d_to_ac[skb->priority]; |
| 65 | } | 112 | } |
| @@ -68,6 +115,12 @@ static u16 classify80211(struct ieee80211_local *local, struct sk_buff *skb) | |||
| 68 | * data frame has */ | 115 | * data frame has */ |
| 69 | skb->priority = cfg80211_classify8021d(skb); | 116 | skb->priority = cfg80211_classify8021d(skb); |
| 70 | 117 | ||
| 118 | return ieee80211_downgrade_queue(local, skb); | ||
| 119 | } | ||
| 120 | |||
| 121 | u16 ieee80211_downgrade_queue(struct ieee80211_local *local, | ||
| 122 | struct sk_buff *skb) | ||
| 123 | { | ||
| 71 | /* in case we are a client verify acm is not set for this ac */ | 124 | /* in case we are a client verify acm is not set for this ac */ |
| 72 | while (unlikely(local->wmm_acm & BIT(skb->priority))) { | 125 | while (unlikely(local->wmm_acm & BIT(skb->priority))) { |
| 73 | if (wme_downgrade_ac(skb)) { | 126 | if (wme_downgrade_ac(skb)) { |
| @@ -85,24 +138,17 @@ static u16 classify80211(struct ieee80211_local *local, struct sk_buff *skb) | |||
| 85 | return ieee802_1d_to_ac[skb->priority]; | 138 | return ieee802_1d_to_ac[skb->priority]; |
| 86 | } | 139 | } |
| 87 | 140 | ||
| 88 | void ieee80211_select_queue(struct ieee80211_local *local, struct sk_buff *skb) | 141 | void ieee80211_set_qos_hdr(struct ieee80211_local *local, struct sk_buff *skb) |
| 89 | { | 142 | { |
| 90 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 143 | struct ieee80211_hdr *hdr = (void *)skb->data; |
| 91 | u16 queue; | 144 | |
| 92 | u8 tid; | 145 | /* Fill in the QoS header if there is one. */ |
| 93 | |||
| 94 | queue = classify80211(local, skb); | ||
| 95 | if (unlikely(queue >= local->hw.queues)) | ||
| 96 | queue = local->hw.queues - 1; | ||
| 97 | |||
| 98 | /* | ||
| 99 | * Now we know the 1d priority, fill in the QoS header if | ||
| 100 | * there is one (and we haven't done this before). | ||
| 101 | */ | ||
| 102 | if (ieee80211_is_data_qos(hdr->frame_control)) { | 146 | if (ieee80211_is_data_qos(hdr->frame_control)) { |
| 103 | u8 *p = ieee80211_get_qos_ctl(hdr); | 147 | u8 *p = ieee80211_get_qos_ctl(hdr); |
| 104 | u8 ack_policy = 0; | 148 | u8 ack_policy = 0, tid; |
| 149 | |||
| 105 | tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; | 150 | tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; |
| 151 | |||
| 106 | if (unlikely(local->wifi_wme_noack_test)) | 152 | if (unlikely(local->wifi_wme_noack_test)) |
| 107 | ack_policy |= QOS_CONTROL_ACK_POLICY_NOACK << | 153 | ack_policy |= QOS_CONTROL_ACK_POLICY_NOACK << |
| 108 | QOS_CONTROL_ACK_POLICY_SHIFT; | 154 | QOS_CONTROL_ACK_POLICY_SHIFT; |
| @@ -110,6 +156,4 @@ void ieee80211_select_queue(struct ieee80211_local *local, struct sk_buff *skb) | |||
| 110 | *p++ = ack_policy | tid; | 156 | *p++ = ack_policy | tid; |
| 111 | *p = 0; | 157 | *p = 0; |
| 112 | } | 158 | } |
| 113 | |||
| 114 | skb_set_queue_mapping(skb, queue); | ||
| 115 | } | 159 | } |
diff --git a/net/mac80211/wme.h b/net/mac80211/wme.h index d4fd87ca5118..6053b1c9feee 100644 --- a/net/mac80211/wme.h +++ b/net/mac80211/wme.h | |||
| @@ -20,7 +20,11 @@ | |||
| 20 | 20 | ||
| 21 | extern const int ieee802_1d_to_ac[8]; | 21 | extern const int ieee802_1d_to_ac[8]; |
| 22 | 22 | ||
| 23 | void ieee80211_select_queue(struct ieee80211_local *local, | 23 | u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata, |
| 24 | struct sk_buff *skb); | 24 | struct sk_buff *skb); |
| 25 | void ieee80211_set_qos_hdr(struct ieee80211_local *local, struct sk_buff *skb); | ||
| 26 | u16 ieee80211_downgrade_queue(struct ieee80211_local *local, | ||
| 27 | struct sk_buff *skb); | ||
| 28 | |||
| 25 | 29 | ||
| 26 | #endif /* _WME_H */ | 30 | #endif /* _WME_H */ |
diff --git a/net/netfilter/ipvs/Kconfig b/net/netfilter/ipvs/Kconfig index 79a698052218..f2d76238b9b5 100644 --- a/net/netfilter/ipvs/Kconfig +++ b/net/netfilter/ipvs/Kconfig | |||
| @@ -112,7 +112,8 @@ config IP_VS_RR | |||
| 112 | module, choose M here. If unsure, say N. | 112 | module, choose M here. If unsure, say N. |
| 113 | 113 | ||
| 114 | config IP_VS_WRR | 114 | config IP_VS_WRR |
| 115 | tristate "weighted round-robin scheduling" | 115 | tristate "weighted round-robin scheduling" |
| 116 | select GCD | ||
| 116 | ---help--- | 117 | ---help--- |
| 117 | The weighted robin-robin scheduling algorithm directs network | 118 | The weighted robin-robin scheduling algorithm directs network |
| 118 | connections to different real servers based on server weights | 119 | connections to different real servers based on server weights |
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c index b95699f00545..847ffca40184 100644 --- a/net/netfilter/ipvs/ip_vs_core.c +++ b/net/netfilter/ipvs/ip_vs_core.c | |||
| @@ -1366,6 +1366,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, | |||
| 1366 | == sysctl_ip_vs_sync_threshold[0])) || | 1366 | == sysctl_ip_vs_sync_threshold[0])) || |
| 1367 | ((cp->protocol == IPPROTO_TCP) && (cp->old_state != cp->state) && | 1367 | ((cp->protocol == IPPROTO_TCP) && (cp->old_state != cp->state) && |
| 1368 | ((cp->state == IP_VS_TCP_S_FIN_WAIT) || | 1368 | ((cp->state == IP_VS_TCP_S_FIN_WAIT) || |
| 1369 | (cp->state == IP_VS_TCP_S_CLOSE) || | ||
| 1369 | (cp->state == IP_VS_TCP_S_CLOSE_WAIT) || | 1370 | (cp->state == IP_VS_TCP_S_CLOSE_WAIT) || |
| 1370 | (cp->state == IP_VS_TCP_S_TIME_WAIT))))) | 1371 | (cp->state == IP_VS_TCP_S_TIME_WAIT))))) |
| 1371 | ip_vs_sync_conn(cp); | 1372 | ip_vs_sync_conn(cp); |
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c index e55a6861d26f..c37ac2d7bec4 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c | |||
| @@ -2077,6 +2077,10 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) | |||
| 2077 | if (!capable(CAP_NET_ADMIN)) | 2077 | if (!capable(CAP_NET_ADMIN)) |
| 2078 | return -EPERM; | 2078 | return -EPERM; |
| 2079 | 2079 | ||
| 2080 | if (cmd < IP_VS_BASE_CTL || cmd > IP_VS_SO_SET_MAX) | ||
| 2081 | return -EINVAL; | ||
| 2082 | if (len < 0 || len > MAX_ARG_LEN) | ||
| 2083 | return -EINVAL; | ||
| 2080 | if (len != set_arglen[SET_CMDID(cmd)]) { | 2084 | if (len != set_arglen[SET_CMDID(cmd)]) { |
| 2081 | pr_err("set_ctl: len %u != %u\n", | 2085 | pr_err("set_ctl: len %u != %u\n", |
| 2082 | len, set_arglen[SET_CMDID(cmd)]); | 2086 | len, set_arglen[SET_CMDID(cmd)]); |
| @@ -2352,17 +2356,25 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) | |||
| 2352 | { | 2356 | { |
| 2353 | unsigned char arg[128]; | 2357 | unsigned char arg[128]; |
| 2354 | int ret = 0; | 2358 | int ret = 0; |
| 2359 | unsigned int copylen; | ||
| 2355 | 2360 | ||
| 2356 | if (!capable(CAP_NET_ADMIN)) | 2361 | if (!capable(CAP_NET_ADMIN)) |
| 2357 | return -EPERM; | 2362 | return -EPERM; |
| 2358 | 2363 | ||
| 2364 | if (cmd < IP_VS_BASE_CTL || cmd > IP_VS_SO_GET_MAX) | ||
| 2365 | return -EINVAL; | ||
| 2366 | |||
| 2359 | if (*len < get_arglen[GET_CMDID(cmd)]) { | 2367 | if (*len < get_arglen[GET_CMDID(cmd)]) { |
| 2360 | pr_err("get_ctl: len %u < %u\n", | 2368 | pr_err("get_ctl: len %u < %u\n", |
| 2361 | *len, get_arglen[GET_CMDID(cmd)]); | 2369 | *len, get_arglen[GET_CMDID(cmd)]); |
| 2362 | return -EINVAL; | 2370 | return -EINVAL; |
| 2363 | } | 2371 | } |
| 2364 | 2372 | ||
| 2365 | if (copy_from_user(arg, user, get_arglen[GET_CMDID(cmd)]) != 0) | 2373 | copylen = get_arglen[GET_CMDID(cmd)]; |
| 2374 | if (copylen > 128) | ||
| 2375 | return -EINVAL; | ||
| 2376 | |||
| 2377 | if (copy_from_user(arg, user, copylen) != 0) | ||
| 2366 | return -EFAULT; | 2378 | return -EFAULT; |
| 2367 | 2379 | ||
| 2368 | if (mutex_lock_interruptible(&__ip_vs_mutex)) | 2380 | if (mutex_lock_interruptible(&__ip_vs_mutex)) |
| @@ -2714,6 +2726,8 @@ static int ip_vs_genl_parse_service(struct ip_vs_service_user_kern *usvc, | |||
| 2714 | if (!(nla_af && (nla_fwmark || (nla_port && nla_protocol && nla_addr)))) | 2726 | if (!(nla_af && (nla_fwmark || (nla_port && nla_protocol && nla_addr)))) |
| 2715 | return -EINVAL; | 2727 | return -EINVAL; |
| 2716 | 2728 | ||
| 2729 | memset(usvc, 0, sizeof(*usvc)); | ||
| 2730 | |||
| 2717 | usvc->af = nla_get_u16(nla_af); | 2731 | usvc->af = nla_get_u16(nla_af); |
| 2718 | #ifdef CONFIG_IP_VS_IPV6 | 2732 | #ifdef CONFIG_IP_VS_IPV6 |
| 2719 | if (usvc->af != AF_INET && usvc->af != AF_INET6) | 2733 | if (usvc->af != AF_INET && usvc->af != AF_INET6) |
| @@ -2901,6 +2915,8 @@ static int ip_vs_genl_parse_dest(struct ip_vs_dest_user_kern *udest, | |||
| 2901 | if (!(nla_addr && nla_port)) | 2915 | if (!(nla_addr && nla_port)) |
| 2902 | return -EINVAL; | 2916 | return -EINVAL; |
| 2903 | 2917 | ||
| 2918 | memset(udest, 0, sizeof(*udest)); | ||
| 2919 | |||
| 2904 | nla_memcpy(&udest->addr, nla_addr, sizeof(udest->addr)); | 2920 | nla_memcpy(&udest->addr, nla_addr, sizeof(udest->addr)); |
| 2905 | udest->port = nla_get_u16(nla_port); | 2921 | udest->port = nla_get_u16(nla_port); |
| 2906 | 2922 | ||
diff --git a/net/netfilter/ipvs/ip_vs_wrr.c b/net/netfilter/ipvs/ip_vs_wrr.c index 6182e8ea0be7..3c115fc19784 100644 --- a/net/netfilter/ipvs/ip_vs_wrr.c +++ b/net/netfilter/ipvs/ip_vs_wrr.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
| 25 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
| 26 | #include <linux/net.h> | 26 | #include <linux/net.h> |
| 27 | #include <linux/gcd.h> | ||
| 27 | 28 | ||
| 28 | #include <net/ip_vs.h> | 29 | #include <net/ip_vs.h> |
| 29 | 30 | ||
| @@ -38,20 +39,6 @@ struct ip_vs_wrr_mark { | |||
| 38 | }; | 39 | }; |
| 39 | 40 | ||
| 40 | 41 | ||
| 41 | /* | ||
| 42 | * Get the gcd of server weights | ||
| 43 | */ | ||
| 44 | static int gcd(int a, int b) | ||
| 45 | { | ||
| 46 | int c; | ||
| 47 | |||
| 48 | while ((c = a % b)) { | ||
| 49 | a = b; | ||
| 50 | b = c; | ||
| 51 | } | ||
| 52 | return b; | ||
| 53 | } | ||
| 54 | |||
| 55 | static int ip_vs_wrr_gcd_weight(struct ip_vs_service *svc) | 42 | static int ip_vs_wrr_gcd_weight(struct ip_vs_service *svc) |
| 56 | { | 43 | { |
| 57 | struct ip_vs_dest *dest; | 44 | struct ip_vs_dest *dest; |
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 0e98c3282d42..4d79e3c1616c 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <linux/netdevice.h> | 30 | #include <linux/netdevice.h> |
| 31 | #include <linux/socket.h> | 31 | #include <linux/socket.h> |
| 32 | #include <linux/mm.h> | 32 | #include <linux/mm.h> |
| 33 | #include <linux/nsproxy.h> | ||
| 33 | #include <linux/rculist_nulls.h> | 34 | #include <linux/rculist_nulls.h> |
| 34 | 35 | ||
| 35 | #include <net/netfilter/nf_conntrack.h> | 36 | #include <net/netfilter/nf_conntrack.h> |
| @@ -63,8 +64,6 @@ EXPORT_SYMBOL_GPL(nf_conntrack_max); | |||
| 63 | struct nf_conn nf_conntrack_untracked __read_mostly; | 64 | struct nf_conn nf_conntrack_untracked __read_mostly; |
| 64 | EXPORT_SYMBOL_GPL(nf_conntrack_untracked); | 65 | EXPORT_SYMBOL_GPL(nf_conntrack_untracked); |
| 65 | 66 | ||
| 66 | static struct kmem_cache *nf_conntrack_cachep __read_mostly; | ||
| 67 | |||
| 68 | static int nf_conntrack_hash_rnd_initted; | 67 | static int nf_conntrack_hash_rnd_initted; |
| 69 | static unsigned int nf_conntrack_hash_rnd; | 68 | static unsigned int nf_conntrack_hash_rnd; |
| 70 | 69 | ||
| @@ -86,9 +85,10 @@ static u_int32_t __hash_conntrack(const struct nf_conntrack_tuple *tuple, | |||
| 86 | return ((u64)h * size) >> 32; | 85 | return ((u64)h * size) >> 32; |
| 87 | } | 86 | } |
| 88 | 87 | ||
| 89 | static inline u_int32_t hash_conntrack(const struct nf_conntrack_tuple *tuple) | 88 | static inline u_int32_t hash_conntrack(const struct net *net, |
| 89 | const struct nf_conntrack_tuple *tuple) | ||
| 90 | { | 90 | { |
| 91 | return __hash_conntrack(tuple, nf_conntrack_htable_size, | 91 | return __hash_conntrack(tuple, net->ct.htable_size, |
| 92 | nf_conntrack_hash_rnd); | 92 | nf_conntrack_hash_rnd); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| @@ -296,7 +296,7 @@ __nf_conntrack_find(struct net *net, const struct nf_conntrack_tuple *tuple) | |||
| 296 | { | 296 | { |
| 297 | struct nf_conntrack_tuple_hash *h; | 297 | struct nf_conntrack_tuple_hash *h; |
| 298 | struct hlist_nulls_node *n; | 298 | struct hlist_nulls_node *n; |
| 299 | unsigned int hash = hash_conntrack(tuple); | 299 | unsigned int hash = hash_conntrack(net, tuple); |
| 300 | 300 | ||
| 301 | /* Disable BHs the entire time since we normally need to disable them | 301 | /* Disable BHs the entire time since we normally need to disable them |
| 302 | * at least once for the stats anyway. | 302 | * at least once for the stats anyway. |
| @@ -366,10 +366,11 @@ static void __nf_conntrack_hash_insert(struct nf_conn *ct, | |||
| 366 | 366 | ||
| 367 | void nf_conntrack_hash_insert(struct nf_conn *ct) | 367 | void nf_conntrack_hash_insert(struct nf_conn *ct) |
| 368 | { | 368 | { |
| 369 | struct net *net = nf_ct_net(ct); | ||
| 369 | unsigned int hash, repl_hash; | 370 | unsigned int hash, repl_hash; |
| 370 | 371 | ||
| 371 | hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); | 372 | hash = hash_conntrack(net, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); |
| 372 | repl_hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple); | 373 | repl_hash = hash_conntrack(net, &ct->tuplehash[IP_CT_DIR_REPLY].tuple); |
| 373 | 374 | ||
| 374 | __nf_conntrack_hash_insert(ct, hash, repl_hash); | 375 | __nf_conntrack_hash_insert(ct, hash, repl_hash); |
| 375 | } | 376 | } |
| @@ -397,8 +398,8 @@ __nf_conntrack_confirm(struct sk_buff *skb) | |||
| 397 | if (CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL) | 398 | if (CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL) |
| 398 | return NF_ACCEPT; | 399 | return NF_ACCEPT; |
| 399 | 400 | ||
| 400 | hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); | 401 | hash = hash_conntrack(net, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); |
| 401 | repl_hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple); | 402 | repl_hash = hash_conntrack(net, &ct->tuplehash[IP_CT_DIR_REPLY].tuple); |
| 402 | 403 | ||
| 403 | /* We're not in hash table, and we refuse to set up related | 404 | /* We're not in hash table, and we refuse to set up related |
| 404 | connections for unconfirmed conns. But packet copies and | 405 | connections for unconfirmed conns. But packet copies and |
| @@ -468,7 +469,7 @@ nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple, | |||
| 468 | struct net *net = nf_ct_net(ignored_conntrack); | 469 | struct net *net = nf_ct_net(ignored_conntrack); |
| 469 | struct nf_conntrack_tuple_hash *h; | 470 | struct nf_conntrack_tuple_hash *h; |
| 470 | struct hlist_nulls_node *n; | 471 | struct hlist_nulls_node *n; |
| 471 | unsigned int hash = hash_conntrack(tuple); | 472 | unsigned int hash = hash_conntrack(net, tuple); |
| 472 | 473 | ||
| 473 | /* Disable BHs the entire time since we need to disable them at | 474 | /* Disable BHs the entire time since we need to disable them at |
| 474 | * least once for the stats anyway. | 475 | * least once for the stats anyway. |
| @@ -503,7 +504,7 @@ static noinline int early_drop(struct net *net, unsigned int hash) | |||
| 503 | int dropped = 0; | 504 | int dropped = 0; |
| 504 | 505 | ||
| 505 | rcu_read_lock(); | 506 | rcu_read_lock(); |
| 506 | for (i = 0; i < nf_conntrack_htable_size; i++) { | 507 | for (i = 0; i < net->ct.htable_size; i++) { |
| 507 | hlist_nulls_for_each_entry_rcu(h, n, &net->ct.hash[hash], | 508 | hlist_nulls_for_each_entry_rcu(h, n, &net->ct.hash[hash], |
| 508 | hnnode) { | 509 | hnnode) { |
| 509 | tmp = nf_ct_tuplehash_to_ctrack(h); | 510 | tmp = nf_ct_tuplehash_to_ctrack(h); |
| @@ -523,7 +524,7 @@ static noinline int early_drop(struct net *net, unsigned int hash) | |||
| 523 | if (cnt >= NF_CT_EVICTION_RANGE) | 524 | if (cnt >= NF_CT_EVICTION_RANGE) |
| 524 | break; | 525 | break; |
| 525 | 526 | ||
| 526 | hash = (hash + 1) % nf_conntrack_htable_size; | 527 | hash = (hash + 1) % net->ct.htable_size; |
| 527 | } | 528 | } |
| 528 | rcu_read_unlock(); | 529 | rcu_read_unlock(); |
| 529 | 530 | ||
| @@ -557,7 +558,7 @@ struct nf_conn *nf_conntrack_alloc(struct net *net, | |||
| 557 | 558 | ||
| 558 | if (nf_conntrack_max && | 559 | if (nf_conntrack_max && |
| 559 | unlikely(atomic_read(&net->ct.count) > nf_conntrack_max)) { | 560 | unlikely(atomic_read(&net->ct.count) > nf_conntrack_max)) { |
| 560 | unsigned int hash = hash_conntrack(orig); | 561 | unsigned int hash = hash_conntrack(net, orig); |
| 561 | if (!early_drop(net, hash)) { | 562 | if (!early_drop(net, hash)) { |
| 562 | atomic_dec(&net->ct.count); | 563 | atomic_dec(&net->ct.count); |
| 563 | if (net_ratelimit()) | 564 | if (net_ratelimit()) |
| @@ -572,7 +573,7 @@ struct nf_conn *nf_conntrack_alloc(struct net *net, | |||
| 572 | * Do not use kmem_cache_zalloc(), as this cache uses | 573 | * Do not use kmem_cache_zalloc(), as this cache uses |
| 573 | * SLAB_DESTROY_BY_RCU. | 574 | * SLAB_DESTROY_BY_RCU. |
| 574 | */ | 575 | */ |
| 575 | ct = kmem_cache_alloc(nf_conntrack_cachep, gfp); | 576 | ct = kmem_cache_alloc(net->ct.nf_conntrack_cachep, gfp); |
| 576 | if (ct == NULL) { | 577 | if (ct == NULL) { |
| 577 | pr_debug("nf_conntrack_alloc: Can't alloc conntrack.\n"); | 578 | pr_debug("nf_conntrack_alloc: Can't alloc conntrack.\n"); |
| 578 | atomic_dec(&net->ct.count); | 579 | atomic_dec(&net->ct.count); |
| @@ -611,7 +612,7 @@ void nf_conntrack_free(struct nf_conn *ct) | |||
| 611 | nf_ct_ext_destroy(ct); | 612 | nf_ct_ext_destroy(ct); |
| 612 | atomic_dec(&net->ct.count); | 613 | atomic_dec(&net->ct.count); |
| 613 | nf_ct_ext_free(ct); | 614 | nf_ct_ext_free(ct); |
| 614 | kmem_cache_free(nf_conntrack_cachep, ct); | 615 | kmem_cache_free(net->ct.nf_conntrack_cachep, ct); |
| 615 | } | 616 | } |
| 616 | EXPORT_SYMBOL_GPL(nf_conntrack_free); | 617 | EXPORT_SYMBOL_GPL(nf_conntrack_free); |
| 617 | 618 | ||
| @@ -1014,7 +1015,7 @@ get_next_corpse(struct net *net, int (*iter)(struct nf_conn *i, void *data), | |||
| 1014 | struct hlist_nulls_node *n; | 1015 | struct hlist_nulls_node *n; |
| 1015 | 1016 | ||
| 1016 | spin_lock_bh(&nf_conntrack_lock); | 1017 | spin_lock_bh(&nf_conntrack_lock); |
| 1017 | for (; *bucket < nf_conntrack_htable_size; (*bucket)++) { | 1018 | for (; *bucket < net->ct.htable_size; (*bucket)++) { |
| 1018 | hlist_nulls_for_each_entry(h, n, &net->ct.hash[*bucket], hnnode) { | 1019 | hlist_nulls_for_each_entry(h, n, &net->ct.hash[*bucket], hnnode) { |
| 1019 | ct = nf_ct_tuplehash_to_ctrack(h); | 1020 | ct = nf_ct_tuplehash_to_ctrack(h); |
| 1020 | if (iter(ct, data)) | 1021 | if (iter(ct, data)) |
| @@ -1113,9 +1114,12 @@ static void nf_ct_release_dying_list(struct net *net) | |||
| 1113 | 1114 | ||
| 1114 | static void nf_conntrack_cleanup_init_net(void) | 1115 | static void nf_conntrack_cleanup_init_net(void) |
| 1115 | { | 1116 | { |
| 1117 | /* wait until all references to nf_conntrack_untracked are dropped */ | ||
| 1118 | while (atomic_read(&nf_conntrack_untracked.ct_general.use) > 1) | ||
| 1119 | schedule(); | ||
| 1120 | |||
| 1116 | nf_conntrack_helper_fini(); | 1121 | nf_conntrack_helper_fini(); |
| 1117 | nf_conntrack_proto_fini(); | 1122 | nf_conntrack_proto_fini(); |
| 1118 | kmem_cache_destroy(nf_conntrack_cachep); | ||
| 1119 | } | 1123 | } |
| 1120 | 1124 | ||
| 1121 | static void nf_conntrack_cleanup_net(struct net *net) | 1125 | static void nf_conntrack_cleanup_net(struct net *net) |
| @@ -1127,15 +1131,14 @@ static void nf_conntrack_cleanup_net(struct net *net) | |||
| 1127 | schedule(); | 1131 | schedule(); |
| 1128 | goto i_see_dead_people; | 1132 | goto i_see_dead_people; |
| 1129 | } | 1133 | } |
| 1130 | /* wait until all references to nf_conntrack_untracked are dropped */ | ||
| 1131 | while (atomic_read(&nf_conntrack_untracked.ct_general.use) > 1) | ||
| 1132 | schedule(); | ||
| 1133 | 1134 | ||
| 1134 | nf_ct_free_hashtable(net->ct.hash, net->ct.hash_vmalloc, | 1135 | nf_ct_free_hashtable(net->ct.hash, net->ct.hash_vmalloc, |
| 1135 | nf_conntrack_htable_size); | 1136 | net->ct.htable_size); |
| 1136 | nf_conntrack_ecache_fini(net); | 1137 | nf_conntrack_ecache_fini(net); |
| 1137 | nf_conntrack_acct_fini(net); | 1138 | nf_conntrack_acct_fini(net); |
| 1138 | nf_conntrack_expect_fini(net); | 1139 | nf_conntrack_expect_fini(net); |
| 1140 | kmem_cache_destroy(net->ct.nf_conntrack_cachep); | ||
| 1141 | kfree(net->ct.slabname); | ||
| 1139 | free_percpu(net->ct.stat); | 1142 | free_percpu(net->ct.stat); |
| 1140 | } | 1143 | } |
| 1141 | 1144 | ||
| @@ -1190,10 +1193,12 @@ int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp) | |||
| 1190 | { | 1193 | { |
| 1191 | int i, bucket, vmalloced, old_vmalloced; | 1194 | int i, bucket, vmalloced, old_vmalloced; |
| 1192 | unsigned int hashsize, old_size; | 1195 | unsigned int hashsize, old_size; |
| 1193 | int rnd; | ||
| 1194 | struct hlist_nulls_head *hash, *old_hash; | 1196 | struct hlist_nulls_head *hash, *old_hash; |
| 1195 | struct nf_conntrack_tuple_hash *h; | 1197 | struct nf_conntrack_tuple_hash *h; |
| 1196 | 1198 | ||
| 1199 | if (current->nsproxy->net_ns != &init_net) | ||
| 1200 | return -EOPNOTSUPP; | ||
| 1201 | |||
| 1197 | /* On boot, we can set this without any fancy locking. */ | 1202 | /* On boot, we can set this without any fancy locking. */ |
| 1198 | if (!nf_conntrack_htable_size) | 1203 | if (!nf_conntrack_htable_size) |
| 1199 | return param_set_uint(val, kp); | 1204 | return param_set_uint(val, kp); |
| @@ -1206,33 +1211,29 @@ int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp) | |||
| 1206 | if (!hash) | 1211 | if (!hash) |
| 1207 | return -ENOMEM; | 1212 | return -ENOMEM; |
| 1208 | 1213 | ||
| 1209 | /* We have to rehahs for the new table anyway, so we also can | ||
| 1210 | * use a newrandom seed */ | ||
| 1211 | get_random_bytes(&rnd, sizeof(rnd)); | ||
| 1212 | |||
| 1213 | /* Lookups in the old hash might happen in parallel, which means we | 1214 | /* Lookups in the old hash might happen in parallel, which means we |
| 1214 | * might get false negatives during connection lookup. New connections | 1215 | * might get false negatives during connection lookup. New connections |
| 1215 | * created because of a false negative won't make it into the hash | 1216 | * created because of a false negative won't make it into the hash |
| 1216 | * though since that required taking the lock. | 1217 | * though since that required taking the lock. |
| 1217 | */ | 1218 | */ |
| 1218 | spin_lock_bh(&nf_conntrack_lock); | 1219 | spin_lock_bh(&nf_conntrack_lock); |
| 1219 | for (i = 0; i < nf_conntrack_htable_size; i++) { | 1220 | for (i = 0; i < init_net.ct.htable_size; i++) { |
| 1220 | while (!hlist_nulls_empty(&init_net.ct.hash[i])) { | 1221 | while (!hlist_nulls_empty(&init_net.ct.hash[i])) { |
| 1221 | h = hlist_nulls_entry(init_net.ct.hash[i].first, | 1222 | h = hlist_nulls_entry(init_net.ct.hash[i].first, |
| 1222 | struct nf_conntrack_tuple_hash, hnnode); | 1223 | struct nf_conntrack_tuple_hash, hnnode); |
| 1223 | hlist_nulls_del_rcu(&h->hnnode); | 1224 | hlist_nulls_del_rcu(&h->hnnode); |
| 1224 | bucket = __hash_conntrack(&h->tuple, hashsize, rnd); | 1225 | bucket = __hash_conntrack(&h->tuple, hashsize, |
| 1226 | nf_conntrack_hash_rnd); | ||
| 1225 | hlist_nulls_add_head_rcu(&h->hnnode, &hash[bucket]); | 1227 | hlist_nulls_add_head_rcu(&h->hnnode, &hash[bucket]); |
| 1226 | } | 1228 | } |
| 1227 | } | 1229 | } |
| 1228 | old_size = nf_conntrack_htable_size; | 1230 | old_size = init_net.ct.htable_size; |
| 1229 | old_vmalloced = init_net.ct.hash_vmalloc; | 1231 | old_vmalloced = init_net.ct.hash_vmalloc; |
| 1230 | old_hash = init_net.ct.hash; | 1232 | old_hash = init_net.ct.hash; |
| 1231 | 1233 | ||
| 1232 | nf_conntrack_htable_size = hashsize; | 1234 | init_net.ct.htable_size = nf_conntrack_htable_size = hashsize; |
| 1233 | init_net.ct.hash_vmalloc = vmalloced; | 1235 | init_net.ct.hash_vmalloc = vmalloced; |
| 1234 | init_net.ct.hash = hash; | 1236 | init_net.ct.hash = hash; |
| 1235 | nf_conntrack_hash_rnd = rnd; | ||
| 1236 | spin_unlock_bh(&nf_conntrack_lock); | 1237 | spin_unlock_bh(&nf_conntrack_lock); |
| 1237 | 1238 | ||
| 1238 | nf_ct_free_hashtable(old_hash, old_vmalloced, old_size); | 1239 | nf_ct_free_hashtable(old_hash, old_vmalloced, old_size); |
| @@ -1271,15 +1272,6 @@ static int nf_conntrack_init_init_net(void) | |||
| 1271 | NF_CONNTRACK_VERSION, nf_conntrack_htable_size, | 1272 | NF_CONNTRACK_VERSION, nf_conntrack_htable_size, |
| 1272 | nf_conntrack_max); | 1273 | nf_conntrack_max); |
| 1273 | 1274 | ||
| 1274 | nf_conntrack_cachep = kmem_cache_create("nf_conntrack", | ||
| 1275 | sizeof(struct nf_conn), | ||
| 1276 | 0, SLAB_DESTROY_BY_RCU, NULL); | ||
| 1277 | if (!nf_conntrack_cachep) { | ||
| 1278 | printk(KERN_ERR "Unable to create nf_conn slab cache\n"); | ||
| 1279 | ret = -ENOMEM; | ||
| 1280 | goto err_cache; | ||
| 1281 | } | ||
| 1282 | |||
| 1283 | ret = nf_conntrack_proto_init(); | 1275 | ret = nf_conntrack_proto_init(); |
| 1284 | if (ret < 0) | 1276 | if (ret < 0) |
| 1285 | goto err_proto; | 1277 | goto err_proto; |
| @@ -1288,13 +1280,19 @@ static int nf_conntrack_init_init_net(void) | |||
| 1288 | if (ret < 0) | 1280 | if (ret < 0) |
| 1289 | goto err_helper; | 1281 | goto err_helper; |
| 1290 | 1282 | ||
| 1283 | /* Set up fake conntrack: to never be deleted, not in any hashes */ | ||
| 1284 | #ifdef CONFIG_NET_NS | ||
| 1285 | nf_conntrack_untracked.ct_net = &init_net; | ||
| 1286 | #endif | ||
| 1287 | atomic_set(&nf_conntrack_untracked.ct_general.use, 1); | ||
| 1288 | /* - and look it like as a confirmed connection */ | ||
| 1289 | set_bit(IPS_CONFIRMED_BIT, &nf_conntrack_untracked.status); | ||
| 1290 | |||
| 1291 | return 0; | 1291 | return 0; |
| 1292 | 1292 | ||
| 1293 | err_helper: | 1293 | err_helper: |
| 1294 | nf_conntrack_proto_fini(); | 1294 | nf_conntrack_proto_fini(); |
| 1295 | err_proto: | 1295 | err_proto: |
| 1296 | kmem_cache_destroy(nf_conntrack_cachep); | ||
| 1297 | err_cache: | ||
| 1298 | return ret; | 1296 | return ret; |
| 1299 | } | 1297 | } |
| 1300 | 1298 | ||
| @@ -1316,7 +1314,24 @@ static int nf_conntrack_init_net(struct net *net) | |||
| 1316 | ret = -ENOMEM; | 1314 | ret = -ENOMEM; |
| 1317 | goto err_stat; | 1315 | goto err_stat; |
| 1318 | } | 1316 | } |
| 1319 | net->ct.hash = nf_ct_alloc_hashtable(&nf_conntrack_htable_size, | 1317 | |
| 1318 | net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net); | ||
| 1319 | if (!net->ct.slabname) { | ||
| 1320 | ret = -ENOMEM; | ||
| 1321 | goto err_slabname; | ||
| 1322 | } | ||
| 1323 | |||
| 1324 | net->ct.nf_conntrack_cachep = kmem_cache_create(net->ct.slabname, | ||
| 1325 | sizeof(struct nf_conn), 0, | ||
| 1326 | SLAB_DESTROY_BY_RCU, NULL); | ||
| 1327 | if (!net->ct.nf_conntrack_cachep) { | ||
| 1328 | printk(KERN_ERR "Unable to create nf_conn slab cache\n"); | ||
| 1329 | ret = -ENOMEM; | ||
| 1330 | goto err_cache; | ||
| 1331 | } | ||
| 1332 | |||
| 1333 | net->ct.htable_size = nf_conntrack_htable_size; | ||
| 1334 | net->ct.hash = nf_ct_alloc_hashtable(&net->ct.htable_size, | ||
| 1320 | &net->ct.hash_vmalloc, 1); | 1335 | &net->ct.hash_vmalloc, 1); |
| 1321 | if (!net->ct.hash) { | 1336 | if (!net->ct.hash) { |
| 1322 | ret = -ENOMEM; | 1337 | ret = -ENOMEM; |
| @@ -1333,15 +1348,6 @@ static int nf_conntrack_init_net(struct net *net) | |||
| 1333 | if (ret < 0) | 1348 | if (ret < 0) |
| 1334 | goto err_ecache; | 1349 | goto err_ecache; |
| 1335 | 1350 | ||
| 1336 | /* Set up fake conntrack: | ||
| 1337 | - to never be deleted, not in any hashes */ | ||
| 1338 | #ifdef CONFIG_NET_NS | ||
| 1339 | nf_conntrack_untracked.ct_net = &init_net; | ||
| 1340 | #endif | ||
| 1341 | atomic_set(&nf_conntrack_untracked.ct_general.use, 1); | ||
| 1342 | /* - and look it like as a confirmed connection */ | ||
| 1343 | set_bit(IPS_CONFIRMED_BIT, &nf_conntrack_untracked.status); | ||
| 1344 | |||
| 1345 | return 0; | 1351 | return 0; |
| 1346 | 1352 | ||
| 1347 | err_ecache: | 1353 | err_ecache: |
| @@ -1350,8 +1356,12 @@ err_acct: | |||
| 1350 | nf_conntrack_expect_fini(net); | 1356 | nf_conntrack_expect_fini(net); |
| 1351 | err_expect: | 1357 | err_expect: |
| 1352 | nf_ct_free_hashtable(net->ct.hash, net->ct.hash_vmalloc, | 1358 | nf_ct_free_hashtable(net->ct.hash, net->ct.hash_vmalloc, |
| 1353 | nf_conntrack_htable_size); | 1359 | net->ct.htable_size); |
| 1354 | err_hash: | 1360 | err_hash: |
| 1361 | kmem_cache_destroy(net->ct.nf_conntrack_cachep); | ||
| 1362 | err_cache: | ||
| 1363 | kfree(net->ct.slabname); | ||
| 1364 | err_slabname: | ||
| 1355 | free_percpu(net->ct.stat); | 1365 | free_percpu(net->ct.stat); |
| 1356 | err_stat: | 1366 | err_stat: |
| 1357 | return ret; | 1367 | return ret; |
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c index fdf5d2a1d9b4..2f25ff610982 100644 --- a/net/netfilter/nf_conntrack_expect.c +++ b/net/netfilter/nf_conntrack_expect.c | |||
| @@ -569,7 +569,7 @@ static void exp_proc_remove(struct net *net) | |||
| 569 | #endif /* CONFIG_PROC_FS */ | 569 | #endif /* CONFIG_PROC_FS */ |
| 570 | } | 570 | } |
| 571 | 571 | ||
| 572 | module_param_named(expect_hashsize, nf_ct_expect_hsize, uint, 0600); | 572 | module_param_named(expect_hashsize, nf_ct_expect_hsize, uint, 0400); |
| 573 | 573 | ||
| 574 | int nf_conntrack_expect_init(struct net *net) | 574 | int nf_conntrack_expect_init(struct net *net) |
| 575 | { | 575 | { |
| @@ -577,7 +577,7 @@ int nf_conntrack_expect_init(struct net *net) | |||
| 577 | 577 | ||
| 578 | if (net_eq(net, &init_net)) { | 578 | if (net_eq(net, &init_net)) { |
| 579 | if (!nf_ct_expect_hsize) { | 579 | if (!nf_ct_expect_hsize) { |
| 580 | nf_ct_expect_hsize = nf_conntrack_htable_size / 256; | 580 | nf_ct_expect_hsize = net->ct.htable_size / 256; |
| 581 | if (!nf_ct_expect_hsize) | 581 | if (!nf_ct_expect_hsize) |
| 582 | nf_ct_expect_hsize = 1; | 582 | nf_ct_expect_hsize = 1; |
| 583 | } | 583 | } |
diff --git a/net/netfilter/nf_conntrack_ftp.c b/net/netfilter/nf_conntrack_ftp.c index 38ea7ef3ccd2..f0732aa18e4f 100644 --- a/net/netfilter/nf_conntrack_ftp.c +++ b/net/netfilter/nf_conntrack_ftp.c | |||
| @@ -323,24 +323,24 @@ static void update_nl_seq(struct nf_conn *ct, u32 nl_seq, | |||
| 323 | struct nf_ct_ftp_master *info, int dir, | 323 | struct nf_ct_ftp_master *info, int dir, |
| 324 | struct sk_buff *skb) | 324 | struct sk_buff *skb) |
| 325 | { | 325 | { |
| 326 | unsigned int i, oldest = NUM_SEQ_TO_REMEMBER; | 326 | unsigned int i, oldest; |
| 327 | 327 | ||
| 328 | /* Look for oldest: if we find exact match, we're done. */ | 328 | /* Look for oldest: if we find exact match, we're done. */ |
| 329 | for (i = 0; i < info->seq_aft_nl_num[dir]; i++) { | 329 | for (i = 0; i < info->seq_aft_nl_num[dir]; i++) { |
| 330 | if (info->seq_aft_nl[dir][i] == nl_seq) | 330 | if (info->seq_aft_nl[dir][i] == nl_seq) |
| 331 | return; | 331 | return; |
| 332 | |||
| 333 | if (oldest == info->seq_aft_nl_num[dir] || | ||
| 334 | before(info->seq_aft_nl[dir][i], | ||
| 335 | info->seq_aft_nl[dir][oldest])) | ||
| 336 | oldest = i; | ||
| 337 | } | 332 | } |
| 338 | 333 | ||
| 339 | if (info->seq_aft_nl_num[dir] < NUM_SEQ_TO_REMEMBER) { | 334 | if (info->seq_aft_nl_num[dir] < NUM_SEQ_TO_REMEMBER) { |
| 340 | info->seq_aft_nl[dir][info->seq_aft_nl_num[dir]++] = nl_seq; | 335 | info->seq_aft_nl[dir][info->seq_aft_nl_num[dir]++] = nl_seq; |
| 341 | } else if (oldest != NUM_SEQ_TO_REMEMBER && | 336 | } else { |
| 342 | after(nl_seq, info->seq_aft_nl[dir][oldest])) { | 337 | if (before(info->seq_aft_nl[dir][0], info->seq_aft_nl[dir][1])) |
| 343 | info->seq_aft_nl[dir][oldest] = nl_seq; | 338 | oldest = 0; |
| 339 | else | ||
| 340 | oldest = 1; | ||
| 341 | |||
| 342 | if (after(nl_seq, info->seq_aft_nl[dir][oldest])) | ||
| 343 | info->seq_aft_nl[dir][oldest] = nl_seq; | ||
| 344 | } | 344 | } |
| 345 | } | 345 | } |
| 346 | 346 | ||
diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c index 65c2a7bc3afc..4b1a56bd074c 100644 --- a/net/netfilter/nf_conntrack_helper.c +++ b/net/netfilter/nf_conntrack_helper.c | |||
| @@ -192,7 +192,7 @@ static void __nf_conntrack_helper_unregister(struct nf_conntrack_helper *me, | |||
| 192 | /* Get rid of expecteds, set helpers to NULL. */ | 192 | /* Get rid of expecteds, set helpers to NULL. */ |
| 193 | hlist_nulls_for_each_entry(h, nn, &net->ct.unconfirmed, hnnode) | 193 | hlist_nulls_for_each_entry(h, nn, &net->ct.unconfirmed, hnnode) |
| 194 | unhelp(h, me); | 194 | unhelp(h, me); |
| 195 | for (i = 0; i < nf_conntrack_htable_size; i++) { | 195 | for (i = 0; i < net->ct.htable_size; i++) { |
| 196 | hlist_nulls_for_each_entry(h, nn, &net->ct.hash[i], hnnode) | 196 | hlist_nulls_for_each_entry(h, nn, &net->ct.hash[i], hnnode) |
| 197 | unhelp(h, me); | 197 | unhelp(h, me); |
| 198 | } | 198 | } |
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 59d8064eb522..0ffe689dfe97 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
| @@ -594,7 +594,7 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 594 | 594 | ||
| 595 | rcu_read_lock(); | 595 | rcu_read_lock(); |
| 596 | last = (struct nf_conn *)cb->args[1]; | 596 | last = (struct nf_conn *)cb->args[1]; |
| 597 | for (; cb->args[0] < nf_conntrack_htable_size; cb->args[0]++) { | 597 | for (; cb->args[0] < init_net.ct.htable_size; cb->args[0]++) { |
| 598 | restart: | 598 | restart: |
| 599 | hlist_nulls_for_each_entry_rcu(h, n, &init_net.ct.hash[cb->args[0]], | 599 | hlist_nulls_for_each_entry_rcu(h, n, &init_net.ct.hash[cb->args[0]], |
| 600 | hnnode) { | 600 | hnnode) { |
| @@ -1437,8 +1437,9 @@ ctnetlink_exp_dump_mask(struct sk_buff *skb, | |||
| 1437 | struct nlattr *nest_parms; | 1437 | struct nlattr *nest_parms; |
| 1438 | 1438 | ||
| 1439 | memset(&m, 0xFF, sizeof(m)); | 1439 | memset(&m, 0xFF, sizeof(m)); |
| 1440 | m.src.u.all = mask->src.u.all; | ||
| 1441 | memcpy(&m.src.u3, &mask->src.u3, sizeof(m.src.u3)); | 1440 | memcpy(&m.src.u3, &mask->src.u3, sizeof(m.src.u3)); |
| 1441 | m.src.u.all = mask->src.u.all; | ||
| 1442 | m.dst.protonum = tuple->dst.protonum; | ||
| 1442 | 1443 | ||
| 1443 | nest_parms = nla_nest_start(skb, CTA_EXPECT_MASK | NLA_F_NESTED); | 1444 | nest_parms = nla_nest_start(skb, CTA_EXPECT_MASK | NLA_F_NESTED); |
| 1444 | if (!nest_parms) | 1445 | if (!nest_parms) |
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c index 4b572163784b..023966b569bf 100644 --- a/net/netfilter/nf_conntrack_sip.c +++ b/net/netfilter/nf_conntrack_sip.c | |||
| @@ -376,7 +376,7 @@ int ct_sip_get_header(const struct nf_conn *ct, const char *dptr, | |||
| 376 | dptr += hdr->len; | 376 | dptr += hdr->len; |
| 377 | else if (hdr->cname && limit - dptr >= hdr->clen + 1 && | 377 | else if (hdr->cname && limit - dptr >= hdr->clen + 1 && |
| 378 | strnicmp(dptr, hdr->cname, hdr->clen) == 0 && | 378 | strnicmp(dptr, hdr->cname, hdr->clen) == 0 && |
| 379 | !isalpha(*(dptr + hdr->clen + 1))) | 379 | !isalpha(*(dptr + hdr->clen))) |
| 380 | dptr += hdr->clen; | 380 | dptr += hdr->clen; |
| 381 | else | 381 | else |
| 382 | continue; | 382 | continue; |
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c index 028aba667ef7..e310f1561bb2 100644 --- a/net/netfilter/nf_conntrack_standalone.c +++ b/net/netfilter/nf_conntrack_standalone.c | |||
| @@ -51,7 +51,7 @@ static struct hlist_nulls_node *ct_get_first(struct seq_file *seq) | |||
| 51 | struct hlist_nulls_node *n; | 51 | struct hlist_nulls_node *n; |
| 52 | 52 | ||
| 53 | for (st->bucket = 0; | 53 | for (st->bucket = 0; |
| 54 | st->bucket < nf_conntrack_htable_size; | 54 | st->bucket < net->ct.htable_size; |
| 55 | st->bucket++) { | 55 | st->bucket++) { |
| 56 | n = rcu_dereference(net->ct.hash[st->bucket].first); | 56 | n = rcu_dereference(net->ct.hash[st->bucket].first); |
| 57 | if (!is_a_nulls(n)) | 57 | if (!is_a_nulls(n)) |
| @@ -69,7 +69,7 @@ static struct hlist_nulls_node *ct_get_next(struct seq_file *seq, | |||
| 69 | head = rcu_dereference(head->next); | 69 | head = rcu_dereference(head->next); |
| 70 | while (is_a_nulls(head)) { | 70 | while (is_a_nulls(head)) { |
| 71 | if (likely(get_nulls_value(head) == st->bucket)) { | 71 | if (likely(get_nulls_value(head) == st->bucket)) { |
| 72 | if (++st->bucket >= nf_conntrack_htable_size) | 72 | if (++st->bucket >= net->ct.htable_size) |
| 73 | return NULL; | 73 | return NULL; |
| 74 | } | 74 | } |
| 75 | head = rcu_dereference(net->ct.hash[st->bucket].first); | 75 | head = rcu_dereference(net->ct.hash[st->bucket].first); |
| @@ -355,7 +355,7 @@ static ctl_table nf_ct_sysctl_table[] = { | |||
| 355 | }, | 355 | }, |
| 356 | { | 356 | { |
| 357 | .procname = "nf_conntrack_buckets", | 357 | .procname = "nf_conntrack_buckets", |
| 358 | .data = &nf_conntrack_htable_size, | 358 | .data = &init_net.ct.htable_size, |
| 359 | .maxlen = sizeof(unsigned int), | 359 | .maxlen = sizeof(unsigned int), |
| 360 | .mode = 0444, | 360 | .mode = 0444, |
| 361 | .proc_handler = proc_dointvec, | 361 | .proc_handler = proc_dointvec, |
| @@ -421,6 +421,7 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net) | |||
| 421 | goto out_kmemdup; | 421 | goto out_kmemdup; |
| 422 | 422 | ||
| 423 | table[1].data = &net->ct.count; | 423 | table[1].data = &net->ct.count; |
| 424 | table[2].data = &net->ct.htable_size; | ||
| 424 | table[3].data = &net->ct.sysctl_checksum; | 425 | table[3].data = &net->ct.sysctl_checksum; |
| 425 | table[4].data = &net->ct.sysctl_log_invalid; | 426 | table[4].data = &net->ct.sysctl_log_invalid; |
| 426 | 427 | ||
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c index eb0ceb846527..fc70a49c0afd 100644 --- a/net/netfilter/xt_recent.c +++ b/net/netfilter/xt_recent.c | |||
| @@ -482,8 +482,7 @@ static ssize_t recent_old_proc_write(struct file *file, | |||
| 482 | if (copy_from_user(buf, input, size)) | 482 | if (copy_from_user(buf, input, size)) |
| 483 | return -EFAULT; | 483 | return -EFAULT; |
| 484 | 484 | ||
| 485 | while (isspace(*c)) | 485 | c = skip_spaces(c); |
| 486 | c++; | ||
| 487 | 486 | ||
| 488 | if (size - (c - buf) < 5) | 487 | if (size - (c - buf) < 5) |
| 489 | return c - buf; | 488 | return c - buf; |
diff --git a/net/netlabel/netlabel_domainhash.c b/net/netlabel/netlabel_domainhash.c index 7a10bbe02c13..c5d9f97ef217 100644 --- a/net/netlabel/netlabel_domainhash.c +++ b/net/netlabel/netlabel_domainhash.c | |||
| @@ -682,7 +682,7 @@ struct netlbl_domaddr6_map *netlbl_domhsh_getentry_af6(const char *domain, | |||
| 682 | * buckets and @skip_chain entries. For each entry in the table call | 682 | * buckets and @skip_chain entries. For each entry in the table call |
| 683 | * @callback, if @callback returns a negative value stop 'walking' through the | 683 | * @callback, if @callback returns a negative value stop 'walking' through the |
| 684 | * table and return. Updates the values in @skip_bkt and @skip_chain on | 684 | * table and return. Updates the values in @skip_bkt and @skip_chain on |
| 685 | * return. Returns zero on succcess, negative values on failure. | 685 | * return. Returns zero on success, negative values on failure. |
| 686 | * | 686 | * |
| 687 | */ | 687 | */ |
| 688 | int netlbl_domhsh_walk(u32 *skip_bkt, | 688 | int netlbl_domhsh_walk(u32 *skip_bkt, |
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index a4957bf2ca60..4c5972ba8c78 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
| @@ -455,9 +455,14 @@ static int netlink_create(struct net *net, struct socket *sock, int protocol, | |||
| 455 | if (nl_table[protocol].registered && | 455 | if (nl_table[protocol].registered && |
| 456 | try_module_get(nl_table[protocol].module)) | 456 | try_module_get(nl_table[protocol].module)) |
| 457 | module = nl_table[protocol].module; | 457 | module = nl_table[protocol].module; |
| 458 | else | ||
| 459 | err = -EPROTONOSUPPORT; | ||
| 458 | cb_mutex = nl_table[protocol].cb_mutex; | 460 | cb_mutex = nl_table[protocol].cb_mutex; |
| 459 | netlink_unlock_table(); | 461 | netlink_unlock_table(); |
| 460 | 462 | ||
| 463 | if (err < 0) | ||
| 464 | goto out; | ||
| 465 | |||
| 461 | err = __netlink_create(net, sock, cb_mutex, protocol); | 466 | err = __netlink_create(net, sock, cb_mutex, protocol); |
| 462 | if (err < 0) | 467 | if (err < 0) |
| 463 | goto out_module; | 468 | goto out_module; |
diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c index aacba76070fc..e2e2d33cafdf 100644 --- a/net/netrom/nr_route.c +++ b/net/netrom/nr_route.c | |||
| @@ -843,12 +843,13 @@ int nr_route_frame(struct sk_buff *skb, ax25_cb *ax25) | |||
| 843 | dptr = skb_push(skb, 1); | 843 | dptr = skb_push(skb, 1); |
| 844 | *dptr = AX25_P_NETROM; | 844 | *dptr = AX25_P_NETROM; |
| 845 | 845 | ||
| 846 | ax25s = ax25_send_frame(skb, 256, (ax25_address *)dev->dev_addr, &nr_neigh->callsign, nr_neigh->digipeat, nr_neigh->dev); | 846 | ax25s = nr_neigh->ax25; |
| 847 | if (nr_neigh->ax25 && ax25s) { | 847 | nr_neigh->ax25 = ax25_send_frame(skb, 256, |
| 848 | /* We were already holding this ax25_cb */ | 848 | (ax25_address *)dev->dev_addr, |
| 849 | &nr_neigh->callsign, | ||
| 850 | nr_neigh->digipeat, nr_neigh->dev); | ||
| 851 | if (ax25s) | ||
| 849 | ax25_cb_put(ax25s); | 852 | ax25_cb_put(ax25s); |
| 850 | } | ||
| 851 | nr_neigh->ax25 = ax25s; | ||
| 852 | 853 | ||
| 853 | dev_put(dev); | 854 | dev_put(dev); |
| 854 | ret = (nr_neigh->ax25 != NULL); | 855 | ret = (nr_neigh->ax25 != NULL); |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 020562164b56..939471ef8d50 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
| @@ -415,7 +415,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, | |||
| 415 | { | 415 | { |
| 416 | struct sock *sk = sock->sk; | 416 | struct sock *sk = sock->sk; |
| 417 | struct sockaddr_pkt *saddr = (struct sockaddr_pkt *)msg->msg_name; | 417 | struct sockaddr_pkt *saddr = (struct sockaddr_pkt *)msg->msg_name; |
| 418 | struct sk_buff *skb; | 418 | struct sk_buff *skb = NULL; |
| 419 | struct net_device *dev; | 419 | struct net_device *dev; |
| 420 | __be16 proto = 0; | 420 | __be16 proto = 0; |
| 421 | int err; | 421 | int err; |
| @@ -437,6 +437,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, | |||
| 437 | */ | 437 | */ |
| 438 | 438 | ||
| 439 | saddr->spkt_device[13] = 0; | 439 | saddr->spkt_device[13] = 0; |
| 440 | retry: | ||
| 440 | rcu_read_lock(); | 441 | rcu_read_lock(); |
| 441 | dev = dev_get_by_name_rcu(sock_net(sk), saddr->spkt_device); | 442 | dev = dev_get_by_name_rcu(sock_net(sk), saddr->spkt_device); |
| 442 | err = -ENODEV; | 443 | err = -ENODEV; |
| @@ -456,58 +457,48 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, | |||
| 456 | if (len > dev->mtu + dev->hard_header_len) | 457 | if (len > dev->mtu + dev->hard_header_len) |
| 457 | goto out_unlock; | 458 | goto out_unlock; |
| 458 | 459 | ||
| 459 | err = -ENOBUFS; | 460 | if (!skb) { |
| 460 | skb = sock_wmalloc(sk, len + LL_RESERVED_SPACE(dev), 0, GFP_KERNEL); | 461 | size_t reserved = LL_RESERVED_SPACE(dev); |
| 461 | 462 | unsigned int hhlen = dev->header_ops ? dev->hard_header_len : 0; | |
| 462 | /* | 463 | |
| 463 | * If the write buffer is full, then tough. At this level the user | 464 | rcu_read_unlock(); |
| 464 | * gets to deal with the problem - do your own algorithmic backoffs. | 465 | skb = sock_wmalloc(sk, len + reserved, 0, GFP_KERNEL); |
| 465 | * That's far more flexible. | 466 | if (skb == NULL) |
| 466 | */ | 467 | return -ENOBUFS; |
| 467 | 468 | /* FIXME: Save some space for broken drivers that write a hard | |
| 468 | if (skb == NULL) | 469 | * header at transmission time by themselves. PPP is the notable |
| 469 | goto out_unlock; | 470 | * one here. This should really be fixed at the driver level. |
| 470 | 471 | */ | |
| 471 | /* | 472 | skb_reserve(skb, reserved); |
| 472 | * Fill it in | 473 | skb_reset_network_header(skb); |
| 473 | */ | 474 | |
| 474 | 475 | /* Try to align data part correctly */ | |
| 475 | /* FIXME: Save some space for broken drivers that write a | 476 | if (hhlen) { |
| 476 | * hard header at transmission time by themselves. PPP is the | 477 | skb->data -= hhlen; |
| 477 | * notable one here. This should really be fixed at the driver level. | 478 | skb->tail -= hhlen; |
| 478 | */ | 479 | if (len < hhlen) |
| 479 | skb_reserve(skb, LL_RESERVED_SPACE(dev)); | 480 | skb_reset_network_header(skb); |
| 480 | skb_reset_network_header(skb); | 481 | } |
| 481 | 482 | err = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len); | |
| 482 | /* Try to align data part correctly */ | 483 | if (err) |
| 483 | if (dev->header_ops) { | 484 | goto out_free; |
| 484 | skb->data -= dev->hard_header_len; | 485 | goto retry; |
| 485 | skb->tail -= dev->hard_header_len; | ||
| 486 | if (len < dev->hard_header_len) | ||
| 487 | skb_reset_network_header(skb); | ||
| 488 | } | 486 | } |
| 489 | 487 | ||
| 490 | /* Returns -EFAULT on error */ | 488 | |
| 491 | err = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len); | ||
| 492 | skb->protocol = proto; | 489 | skb->protocol = proto; |
| 493 | skb->dev = dev; | 490 | skb->dev = dev; |
| 494 | skb->priority = sk->sk_priority; | 491 | skb->priority = sk->sk_priority; |
| 495 | skb->mark = sk->sk_mark; | 492 | skb->mark = sk->sk_mark; |
| 496 | if (err) | ||
| 497 | goto out_free; | ||
| 498 | |||
| 499 | /* | ||
| 500 | * Now send it | ||
| 501 | */ | ||
| 502 | 493 | ||
| 503 | dev_queue_xmit(skb); | 494 | dev_queue_xmit(skb); |
| 504 | rcu_read_unlock(); | 495 | rcu_read_unlock(); |
| 505 | return len; | 496 | return len; |
| 506 | 497 | ||
| 507 | out_free: | ||
| 508 | kfree_skb(skb); | ||
| 509 | out_unlock: | 498 | out_unlock: |
| 510 | rcu_read_unlock(); | 499 | rcu_read_unlock(); |
| 500 | out_free: | ||
| 501 | kfree_skb(skb); | ||
| 511 | return err; | 502 | return err; |
| 512 | } | 503 | } |
| 513 | 504 | ||
| @@ -517,7 +508,7 @@ static inline unsigned int run_filter(struct sk_buff *skb, struct sock *sk, | |||
| 517 | struct sk_filter *filter; | 508 | struct sk_filter *filter; |
| 518 | 509 | ||
| 519 | rcu_read_lock_bh(); | 510 | rcu_read_lock_bh(); |
| 520 | filter = rcu_dereference(sk->sk_filter); | 511 | filter = rcu_dereference_bh(sk->sk_filter); |
| 521 | if (filter != NULL) | 512 | if (filter != NULL) |
| 522 | res = sk_run_filter(skb, filter->insns, filter->len); | 513 | res = sk_run_filter(skb, filter->insns, filter->len); |
| 523 | rcu_read_unlock_bh(); | 514 | rcu_read_unlock_bh(); |
| @@ -1030,8 +1021,20 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg) | |||
| 1030 | 1021 | ||
| 1031 | status = TP_STATUS_SEND_REQUEST; | 1022 | status = TP_STATUS_SEND_REQUEST; |
| 1032 | err = dev_queue_xmit(skb); | 1023 | err = dev_queue_xmit(skb); |
| 1033 | if (unlikely(err > 0 && (err = net_xmit_errno(err)) != 0)) | 1024 | if (unlikely(err > 0)) { |
| 1034 | goto out_xmit; | 1025 | err = net_xmit_errno(err); |
| 1026 | if (err && __packet_get_status(po, ph) == | ||
| 1027 | TP_STATUS_AVAILABLE) { | ||
| 1028 | /* skb was destructed already */ | ||
| 1029 | skb = NULL; | ||
| 1030 | goto out_status; | ||
| 1031 | } | ||
| 1032 | /* | ||
| 1033 | * skb was dropped but not destructed yet; | ||
| 1034 | * let's treat it like congestion or err < 0 | ||
| 1035 | */ | ||
| 1036 | err = 0; | ||
| 1037 | } | ||
| 1035 | packet_increment_head(&po->tx_ring); | 1038 | packet_increment_head(&po->tx_ring); |
| 1036 | len_sum += tp_len; | 1039 | len_sum += tp_len; |
| 1037 | } while (likely((ph != NULL) || | 1040 | } while (likely((ph != NULL) || |
| @@ -1042,9 +1045,6 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg) | |||
| 1042 | err = len_sum; | 1045 | err = len_sum; |
| 1043 | goto out_put; | 1046 | goto out_put; |
| 1044 | 1047 | ||
| 1045 | out_xmit: | ||
| 1046 | skb->destructor = sock_wfree; | ||
| 1047 | atomic_dec(&po->tx_ring.pending); | ||
| 1048 | out_status: | 1048 | out_status: |
| 1049 | __packet_set_status(po, ph, status); | 1049 | __packet_set_status(po, ph, status); |
| 1050 | kfree_skb(skb); | 1050 | kfree_skb(skb); |
diff --git a/net/rds/ib.c b/net/rds/ib.c index 536ebe5d3f6b..3b8992361042 100644 --- a/net/rds/ib.c +++ b/net/rds/ib.c | |||
| @@ -182,8 +182,8 @@ static int rds_ib_conn_info_visitor(struct rds_connection *conn, | |||
| 182 | ic = conn->c_transport_data; | 182 | ic = conn->c_transport_data; |
| 183 | dev_addr = &ic->i_cm_id->route.addr.dev_addr; | 183 | dev_addr = &ic->i_cm_id->route.addr.dev_addr; |
| 184 | 184 | ||
| 185 | ib_addr_get_sgid(dev_addr, (union ib_gid *) &iinfo->src_gid); | 185 | rdma_addr_get_sgid(dev_addr, (union ib_gid *) &iinfo->src_gid); |
| 186 | ib_addr_get_dgid(dev_addr, (union ib_gid *) &iinfo->dst_gid); | 186 | rdma_addr_get_dgid(dev_addr, (union ib_gid *) &iinfo->dst_gid); |
| 187 | 187 | ||
| 188 | rds_ibdev = ib_get_client_data(ic->i_cm_id->device, &rds_ib_client); | 188 | rds_ibdev = ib_get_client_data(ic->i_cm_id->device, &rds_ib_client); |
| 189 | iinfo->max_send_wr = ic->i_send_ring.w_nr; | 189 | iinfo->max_send_wr = ic->i_send_ring.w_nr; |
diff --git a/net/rds/iw.c b/net/rds/iw.c index db224f7c2937..b28fa8525b24 100644 --- a/net/rds/iw.c +++ b/net/rds/iw.c | |||
| @@ -184,8 +184,8 @@ static int rds_iw_conn_info_visitor(struct rds_connection *conn, | |||
| 184 | ic = conn->c_transport_data; | 184 | ic = conn->c_transport_data; |
| 185 | dev_addr = &ic->i_cm_id->route.addr.dev_addr; | 185 | dev_addr = &ic->i_cm_id->route.addr.dev_addr; |
| 186 | 186 | ||
| 187 | ib_addr_get_sgid(dev_addr, (union ib_gid *) &iinfo->src_gid); | 187 | rdma_addr_get_sgid(dev_addr, (union ib_gid *) &iinfo->src_gid); |
| 188 | ib_addr_get_dgid(dev_addr, (union ib_gid *) &iinfo->dst_gid); | 188 | rdma_addr_get_dgid(dev_addr, (union ib_gid *) &iinfo->dst_gid); |
| 189 | 189 | ||
| 190 | rds_iwdev = ib_get_client_data(ic->i_cm_id->device, &rds_iw_client); | 190 | rds_iwdev = ib_get_client_data(ic->i_cm_id->device, &rds_iw_client); |
| 191 | iinfo->max_send_wr = ic->i_send_ring.w_nr; | 191 | iinfo->max_send_wr = ic->i_send_ring.w_nr; |
diff --git a/net/rfkill/core.c b/net/rfkill/core.c index 448e5a0fcc2e..c218e07e5caf 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c | |||
| @@ -579,6 +579,8 @@ static ssize_t rfkill_name_show(struct device *dev, | |||
| 579 | 579 | ||
| 580 | static const char *rfkill_get_type_str(enum rfkill_type type) | 580 | static const char *rfkill_get_type_str(enum rfkill_type type) |
| 581 | { | 581 | { |
| 582 | BUILD_BUG_ON(NUM_RFKILL_TYPES != RFKILL_TYPE_FM + 1); | ||
| 583 | |||
| 582 | switch (type) { | 584 | switch (type) { |
| 583 | case RFKILL_TYPE_WLAN: | 585 | case RFKILL_TYPE_WLAN: |
| 584 | return "wlan"; | 586 | return "wlan"; |
| @@ -597,8 +599,6 @@ static const char *rfkill_get_type_str(enum rfkill_type type) | |||
| 597 | default: | 599 | default: |
| 598 | BUG(); | 600 | BUG(); |
| 599 | } | 601 | } |
| 600 | |||
| 601 | BUILD_BUG_ON(NUM_RFKILL_TYPES != RFKILL_TYPE_FM + 1); | ||
| 602 | } | 602 | } |
| 603 | 603 | ||
| 604 | static ssize_t rfkill_type_show(struct device *dev, | 604 | static ssize_t rfkill_type_show(struct device *dev, |
diff --git a/net/rose/rose_link.c b/net/rose/rose_link.c index bd86a63960ce..5ef5f6988a2e 100644 --- a/net/rose/rose_link.c +++ b/net/rose/rose_link.c | |||
| @@ -101,13 +101,17 @@ static void rose_t0timer_expiry(unsigned long param) | |||
| 101 | static int rose_send_frame(struct sk_buff *skb, struct rose_neigh *neigh) | 101 | static int rose_send_frame(struct sk_buff *skb, struct rose_neigh *neigh) |
| 102 | { | 102 | { |
| 103 | ax25_address *rose_call; | 103 | ax25_address *rose_call; |
| 104 | ax25_cb *ax25s; | ||
| 104 | 105 | ||
| 105 | if (ax25cmp(&rose_callsign, &null_ax25_address) == 0) | 106 | if (ax25cmp(&rose_callsign, &null_ax25_address) == 0) |
| 106 | rose_call = (ax25_address *)neigh->dev->dev_addr; | 107 | rose_call = (ax25_address *)neigh->dev->dev_addr; |
| 107 | else | 108 | else |
| 108 | rose_call = &rose_callsign; | 109 | rose_call = &rose_callsign; |
| 109 | 110 | ||
| 111 | ax25s = neigh->ax25; | ||
| 110 | neigh->ax25 = ax25_send_frame(skb, 260, rose_call, &neigh->callsign, neigh->digipeat, neigh->dev); | 112 | neigh->ax25 = ax25_send_frame(skb, 260, rose_call, &neigh->callsign, neigh->digipeat, neigh->dev); |
| 113 | if (ax25s) | ||
| 114 | ax25_cb_put(ax25s); | ||
| 111 | 115 | ||
| 112 | return (neigh->ax25 != NULL); | 116 | return (neigh->ax25 != NULL); |
| 113 | } | 117 | } |
| @@ -120,13 +124,17 @@ static int rose_send_frame(struct sk_buff *skb, struct rose_neigh *neigh) | |||
| 120 | static int rose_link_up(struct rose_neigh *neigh) | 124 | static int rose_link_up(struct rose_neigh *neigh) |
| 121 | { | 125 | { |
| 122 | ax25_address *rose_call; | 126 | ax25_address *rose_call; |
| 127 | ax25_cb *ax25s; | ||
| 123 | 128 | ||
| 124 | if (ax25cmp(&rose_callsign, &null_ax25_address) == 0) | 129 | if (ax25cmp(&rose_callsign, &null_ax25_address) == 0) |
| 125 | rose_call = (ax25_address *)neigh->dev->dev_addr; | 130 | rose_call = (ax25_address *)neigh->dev->dev_addr; |
| 126 | else | 131 | else |
| 127 | rose_call = &rose_callsign; | 132 | rose_call = &rose_callsign; |
| 128 | 133 | ||
| 134 | ax25s = neigh->ax25; | ||
| 129 | neigh->ax25 = ax25_find_cb(rose_call, &neigh->callsign, neigh->digipeat, neigh->dev); | 135 | neigh->ax25 = ax25_find_cb(rose_call, &neigh->callsign, neigh->digipeat, neigh->dev); |
| 136 | if (ax25s) | ||
| 137 | ax25_cb_put(ax25s); | ||
| 130 | 138 | ||
| 131 | return (neigh->ax25 != NULL); | 139 | return (neigh->ax25 != NULL); |
| 132 | } | 140 | } |
diff --git a/net/rose/rose_loopback.c b/net/rose/rose_loopback.c index 114df6eec8c3..968e8bac1b5d 100644 --- a/net/rose/rose_loopback.c +++ b/net/rose/rose_loopback.c | |||
| @@ -75,7 +75,7 @@ static void rose_loopback_timer(unsigned long param) | |||
| 75 | lci_i = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF); | 75 | lci_i = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF); |
| 76 | frametype = skb->data[2]; | 76 | frametype = skb->data[2]; |
| 77 | dest = (rose_address *)(skb->data + 4); | 77 | dest = (rose_address *)(skb->data + 4); |
| 78 | lci_o = 0xFFF - lci_i; | 78 | lci_o = ROSE_DEFAULT_MAXVC + 1 - lci_i; |
| 79 | 79 | ||
| 80 | skb_reset_transport_header(skb); | 80 | skb_reset_transport_header(skb); |
| 81 | 81 | ||
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c index 795c4b025e31..70a0b3b4b4d2 100644 --- a/net/rose/rose_route.c +++ b/net/rose/rose_route.c | |||
| @@ -235,6 +235,8 @@ static void rose_remove_neigh(struct rose_neigh *rose_neigh) | |||
| 235 | 235 | ||
| 236 | if ((s = rose_neigh_list) == rose_neigh) { | 236 | if ((s = rose_neigh_list) == rose_neigh) { |
| 237 | rose_neigh_list = rose_neigh->next; | 237 | rose_neigh_list = rose_neigh->next; |
| 238 | if (rose_neigh->ax25) | ||
| 239 | ax25_cb_put(rose_neigh->ax25); | ||
| 238 | kfree(rose_neigh->digipeat); | 240 | kfree(rose_neigh->digipeat); |
| 239 | kfree(rose_neigh); | 241 | kfree(rose_neigh); |
| 240 | return; | 242 | return; |
| @@ -243,6 +245,8 @@ static void rose_remove_neigh(struct rose_neigh *rose_neigh) | |||
| 243 | while (s != NULL && s->next != NULL) { | 245 | while (s != NULL && s->next != NULL) { |
| 244 | if (s->next == rose_neigh) { | 246 | if (s->next == rose_neigh) { |
| 245 | s->next = rose_neigh->next; | 247 | s->next = rose_neigh->next; |
| 248 | if (rose_neigh->ax25) | ||
| 249 | ax25_cb_put(rose_neigh->ax25); | ||
| 246 | kfree(rose_neigh->digipeat); | 250 | kfree(rose_neigh->digipeat); |
| 247 | kfree(rose_neigh); | 251 | kfree(rose_neigh); |
| 248 | return; | 252 | return; |
| @@ -812,6 +816,7 @@ void rose_link_failed(ax25_cb *ax25, int reason) | |||
| 812 | 816 | ||
| 813 | if (rose_neigh != NULL) { | 817 | if (rose_neigh != NULL) { |
| 814 | rose_neigh->ax25 = NULL; | 818 | rose_neigh->ax25 = NULL; |
| 819 | ax25_cb_put(ax25); | ||
| 815 | 820 | ||
| 816 | rose_del_route_by_neigh(rose_neigh); | 821 | rose_del_route_by_neigh(rose_neigh); |
| 817 | rose_kill_by_neigh(rose_neigh); | 822 | rose_kill_by_neigh(rose_neigh); |
diff --git a/net/sched/Kconfig b/net/sched/Kconfig index 929218a47620..21f9c7678aa3 100644 --- a/net/sched/Kconfig +++ b/net/sched/Kconfig | |||
| @@ -433,7 +433,7 @@ config NET_ACT_POLICE | |||
| 433 | module. | 433 | module. |
| 434 | 434 | ||
| 435 | To compile this code as a module, choose M here: the | 435 | To compile this code as a module, choose M here: the |
| 436 | module will be called police. | 436 | module will be called act_police. |
| 437 | 437 | ||
| 438 | config NET_ACT_GACT | 438 | config NET_ACT_GACT |
| 439 | tristate "Generic actions" | 439 | tristate "Generic actions" |
| @@ -443,7 +443,7 @@ config NET_ACT_GACT | |||
| 443 | accepting packets. | 443 | accepting packets. |
| 444 | 444 | ||
| 445 | To compile this code as a module, choose M here: the | 445 | To compile this code as a module, choose M here: the |
| 446 | module will be called gact. | 446 | module will be called act_gact. |
| 447 | 447 | ||
| 448 | config GACT_PROB | 448 | config GACT_PROB |
| 449 | bool "Probability support" | 449 | bool "Probability support" |
| @@ -459,7 +459,7 @@ config NET_ACT_MIRRED | |||
| 459 | other devices. | 459 | other devices. |
| 460 | 460 | ||
| 461 | To compile this code as a module, choose M here: the | 461 | To compile this code as a module, choose M here: the |
| 462 | module will be called mirred. | 462 | module will be called act_mirred. |
| 463 | 463 | ||
| 464 | config NET_ACT_IPT | 464 | config NET_ACT_IPT |
| 465 | tristate "IPtables targets" | 465 | tristate "IPtables targets" |
| @@ -469,7 +469,7 @@ config NET_ACT_IPT | |||
| 469 | classification. | 469 | classification. |
| 470 | 470 | ||
| 471 | To compile this code as a module, choose M here: the | 471 | To compile this code as a module, choose M here: the |
| 472 | module will be called ipt. | 472 | module will be called act_ipt. |
| 473 | 473 | ||
| 474 | config NET_ACT_NAT | 474 | config NET_ACT_NAT |
| 475 | tristate "Stateless NAT" | 475 | tristate "Stateless NAT" |
| @@ -479,7 +479,7 @@ config NET_ACT_NAT | |||
| 479 | netfilter for NAT unless you know what you are doing. | 479 | netfilter for NAT unless you know what you are doing. |
| 480 | 480 | ||
| 481 | To compile this code as a module, choose M here: the | 481 | To compile this code as a module, choose M here: the |
| 482 | module will be called nat. | 482 | module will be called act_nat. |
| 483 | 483 | ||
| 484 | config NET_ACT_PEDIT | 484 | config NET_ACT_PEDIT |
| 485 | tristate "Packet Editing" | 485 | tristate "Packet Editing" |
| @@ -488,7 +488,7 @@ config NET_ACT_PEDIT | |||
| 488 | Say Y here if you want to mangle the content of packets. | 488 | Say Y here if you want to mangle the content of packets. |
| 489 | 489 | ||
| 490 | To compile this code as a module, choose M here: the | 490 | To compile this code as a module, choose M here: the |
| 491 | module will be called pedit. | 491 | module will be called act_pedit. |
| 492 | 492 | ||
| 493 | config NET_ACT_SIMP | 493 | config NET_ACT_SIMP |
| 494 | tristate "Simple Example (Debug)" | 494 | tristate "Simple Example (Debug)" |
| @@ -502,7 +502,7 @@ config NET_ACT_SIMP | |||
| 502 | If unsure, say N. | 502 | If unsure, say N. |
| 503 | 503 | ||
| 504 | To compile this code as a module, choose M here: the | 504 | To compile this code as a module, choose M here: the |
| 505 | module will be called simple. | 505 | module will be called act_simple. |
| 506 | 506 | ||
| 507 | config NET_ACT_SKBEDIT | 507 | config NET_ACT_SKBEDIT |
| 508 | tristate "SKB Editing" | 508 | tristate "SKB Editing" |
| @@ -513,7 +513,7 @@ config NET_ACT_SKBEDIT | |||
| 513 | If unsure, say N. | 513 | If unsure, say N. |
| 514 | 514 | ||
| 515 | To compile this code as a module, choose M here: the | 515 | To compile this code as a module, choose M here: the |
| 516 | module will be called skbedit. | 516 | module will be called act_skbedit. |
| 517 | 517 | ||
| 518 | config NET_CLS_IND | 518 | config NET_CLS_IND |
| 519 | bool "Incoming device classification" | 519 | bool "Incoming device classification" |
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 2a740035aa6b..64f5e328cee9 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
| @@ -598,7 +598,7 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a, | |||
| 598 | goto errout; | 598 | goto errout; |
| 599 | 599 | ||
| 600 | /* compat_mode being true specifies a call that is supposed | 600 | /* compat_mode being true specifies a call that is supposed |
| 601 | * to add additional backward compatiblity statistic TLVs. | 601 | * to add additional backward compatibility statistic TLVs. |
| 602 | */ | 602 | */ |
| 603 | if (compat_mode) { | 603 | if (compat_mode) { |
| 604 | if (a->type == TCA_OLD_COMPAT) | 604 | if (a->type == TCA_OLD_COMPAT) |
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c index d771cc1b777a..4e4ca65cd320 100644 --- a/net/sctp/sm_sideeffect.c +++ b/net/sctp/sm_sideeffect.c | |||
| @@ -717,7 +717,7 @@ static void sctp_cmd_new_state(sctp_cmd_seq_t *cmds, | |||
| 717 | 717 | ||
| 718 | if (sctp_style(sk, TCP)) { | 718 | if (sctp_style(sk, TCP)) { |
| 719 | /* Change the sk->sk_state of a TCP-style socket that has | 719 | /* Change the sk->sk_state of a TCP-style socket that has |
| 720 | * sucessfully completed a connect() call. | 720 | * successfully completed a connect() call. |
| 721 | */ | 721 | */ |
| 722 | if (sctp_state(asoc, ESTABLISHED) && sctp_sstate(sk, CLOSED)) | 722 | if (sctp_state(asoc, ESTABLISHED) && sctp_sstate(sk, CLOSED)) |
| 723 | sk->sk_state = SCTP_SS_ESTABLISHED; | 723 | sk->sk_state = SCTP_SS_ESTABLISHED; |
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index 1ef9de9bbae9..47bc20d3a85b 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c | |||
| @@ -3577,7 +3577,7 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep, | |||
| 3577 | * To do this properly, we'll set the destination address of the chunk | 3577 | * To do this properly, we'll set the destination address of the chunk |
| 3578 | * and at the transmit time, will try look up the transport to use. | 3578 | * and at the transmit time, will try look up the transport to use. |
| 3579 | * Since ASCONFs may be bundled, the correct transport may not be | 3579 | * Since ASCONFs may be bundled, the correct transport may not be |
| 3580 | * created untill we process the entire packet, thus this workaround. | 3580 | * created until we process the entire packet, thus this workaround. |
| 3581 | */ | 3581 | */ |
| 3582 | asconf_ack->dest = chunk->source; | 3582 | asconf_ack->dest = chunk->source; |
| 3583 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(asconf_ack)); | 3583 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(asconf_ack)); |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 89ab66e54740..67fdac9d2d33 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
| @@ -2087,8 +2087,7 @@ static int sctp_setsockopt_autoclose(struct sock *sk, char __user *optval, | |||
| 2087 | if (copy_from_user(&sp->autoclose, optval, optlen)) | 2087 | if (copy_from_user(&sp->autoclose, optval, optlen)) |
| 2088 | return -EFAULT; | 2088 | return -EFAULT; |
| 2089 | /* make sure it won't exceed MAX_SCHEDULE_TIMEOUT */ | 2089 | /* make sure it won't exceed MAX_SCHEDULE_TIMEOUT */ |
| 2090 | if (sp->autoclose > (MAX_SCHEDULE_TIMEOUT / HZ) ) | 2090 | sp->autoclose = min_t(long, sp->autoclose, MAX_SCHEDULE_TIMEOUT / HZ); |
| 2091 | sp->autoclose = (__u32)(MAX_SCHEDULE_TIMEOUT / HZ) ; | ||
| 2092 | 2091 | ||
| 2093 | return 0; | 2092 | return 0; |
| 2094 | } | 2093 | } |
diff --git a/net/socket.c b/net/socket.c index b94c3dd71015..769c386bd428 100644 --- a/net/socket.c +++ b/net/socket.c | |||
| @@ -312,18 +312,6 @@ static struct file_system_type sock_fs_type = { | |||
| 312 | .kill_sb = kill_anon_super, | 312 | .kill_sb = kill_anon_super, |
| 313 | }; | 313 | }; |
| 314 | 314 | ||
| 315 | static int sockfs_delete_dentry(struct dentry *dentry) | ||
| 316 | { | ||
| 317 | /* | ||
| 318 | * At creation time, we pretended this dentry was hashed | ||
| 319 | * (by clearing DCACHE_UNHASHED bit in d_flags) | ||
| 320 | * At delete time, we restore the truth : not hashed. | ||
| 321 | * (so that dput() can proceed correctly) | ||
| 322 | */ | ||
| 323 | dentry->d_flags |= DCACHE_UNHASHED; | ||
| 324 | return 0; | ||
| 325 | } | ||
| 326 | |||
| 327 | /* | 315 | /* |
| 328 | * sockfs_dname() is called from d_path(). | 316 | * sockfs_dname() is called from d_path(). |
| 329 | */ | 317 | */ |
| @@ -334,7 +322,6 @@ static char *sockfs_dname(struct dentry *dentry, char *buffer, int buflen) | |||
| 334 | } | 322 | } |
| 335 | 323 | ||
| 336 | static const struct dentry_operations sockfs_dentry_operations = { | 324 | static const struct dentry_operations sockfs_dentry_operations = { |
| 337 | .d_delete = sockfs_delete_dentry, | ||
| 338 | .d_dname = sockfs_dname, | 325 | .d_dname = sockfs_dname, |
| 339 | }; | 326 | }; |
| 340 | 327 | ||
| @@ -355,68 +342,55 @@ static const struct dentry_operations sockfs_dentry_operations = { | |||
| 355 | * but we take care of internal coherence yet. | 342 | * but we take care of internal coherence yet. |
| 356 | */ | 343 | */ |
| 357 | 344 | ||
| 358 | static int sock_alloc_fd(struct file **filep, int flags) | 345 | static int sock_alloc_file(struct socket *sock, struct file **f, int flags) |
| 359 | { | 346 | { |
| 347 | struct qstr name = { .name = "" }; | ||
| 348 | struct path path; | ||
| 349 | struct file *file; | ||
| 360 | int fd; | 350 | int fd; |
| 361 | 351 | ||
| 362 | fd = get_unused_fd_flags(flags); | 352 | fd = get_unused_fd_flags(flags); |
| 363 | if (likely(fd >= 0)) { | 353 | if (unlikely(fd < 0)) |
| 364 | struct file *file = get_empty_filp(); | 354 | return fd; |
| 365 | |||
| 366 | *filep = file; | ||
| 367 | if (unlikely(!file)) { | ||
| 368 | put_unused_fd(fd); | ||
| 369 | return -ENFILE; | ||
| 370 | } | ||
| 371 | } else | ||
| 372 | *filep = NULL; | ||
| 373 | return fd; | ||
| 374 | } | ||
| 375 | |||
| 376 | static int sock_attach_fd(struct socket *sock, struct file *file, int flags) | ||
| 377 | { | ||
| 378 | struct dentry *dentry; | ||
| 379 | struct qstr name = { .name = "" }; | ||
| 380 | 355 | ||
| 381 | dentry = d_alloc(sock_mnt->mnt_sb->s_root, &name); | 356 | path.dentry = d_alloc(sock_mnt->mnt_sb->s_root, &name); |
| 382 | if (unlikely(!dentry)) | 357 | if (unlikely(!path.dentry)) { |
| 358 | put_unused_fd(fd); | ||
| 383 | return -ENOMEM; | 359 | return -ENOMEM; |
| 360 | } | ||
| 361 | path.mnt = mntget(sock_mnt); | ||
| 384 | 362 | ||
| 385 | dentry->d_op = &sockfs_dentry_operations; | 363 | path.dentry->d_op = &sockfs_dentry_operations; |
| 386 | /* | 364 | d_instantiate(path.dentry, SOCK_INODE(sock)); |
| 387 | * We dont want to push this dentry into global dentry hash table. | 365 | SOCK_INODE(sock)->i_fop = &socket_file_ops; |
| 388 | * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED | ||
| 389 | * This permits a working /proc/$pid/fd/XXX on sockets | ||
| 390 | */ | ||
| 391 | dentry->d_flags &= ~DCACHE_UNHASHED; | ||
| 392 | d_instantiate(dentry, SOCK_INODE(sock)); | ||
| 393 | 366 | ||
| 394 | sock->file = file; | 367 | file = alloc_file(&path, FMODE_READ | FMODE_WRITE, |
| 395 | init_file(file, sock_mnt, dentry, FMODE_READ | FMODE_WRITE, | ||
| 396 | &socket_file_ops); | 368 | &socket_file_ops); |
| 397 | SOCK_INODE(sock)->i_fop = &socket_file_ops; | 369 | if (unlikely(!file)) { |
| 370 | /* drop dentry, keep inode */ | ||
| 371 | atomic_inc(&path.dentry->d_inode->i_count); | ||
| 372 | path_put(&path); | ||
| 373 | put_unused_fd(fd); | ||
| 374 | return -ENFILE; | ||
| 375 | } | ||
| 376 | |||
| 377 | sock->file = file; | ||
| 398 | file->f_flags = O_RDWR | (flags & O_NONBLOCK); | 378 | file->f_flags = O_RDWR | (flags & O_NONBLOCK); |
| 399 | file->f_pos = 0; | 379 | file->f_pos = 0; |
| 400 | file->private_data = sock; | 380 | file->private_data = sock; |
| 401 | 381 | ||
| 402 | return 0; | 382 | *f = file; |
| 383 | return fd; | ||
| 403 | } | 384 | } |
| 404 | 385 | ||
| 405 | int sock_map_fd(struct socket *sock, int flags) | 386 | int sock_map_fd(struct socket *sock, int flags) |
| 406 | { | 387 | { |
| 407 | struct file *newfile; | 388 | struct file *newfile; |
| 408 | int fd = sock_alloc_fd(&newfile, flags); | 389 | int fd = sock_alloc_file(sock, &newfile, flags); |
| 409 | 390 | ||
| 410 | if (likely(fd >= 0)) { | 391 | if (likely(fd >= 0)) |
| 411 | int err = sock_attach_fd(sock, newfile, flags); | ||
| 412 | |||
| 413 | if (unlikely(err < 0)) { | ||
| 414 | put_filp(newfile); | ||
| 415 | put_unused_fd(fd); | ||
| 416 | return err; | ||
| 417 | } | ||
| 418 | fd_install(fd, newfile); | 392 | fd_install(fd, newfile); |
| 419 | } | 393 | |
| 420 | return fd; | 394 | return fd; |
| 421 | } | 395 | } |
| 422 | 396 | ||
| @@ -1390,29 +1364,19 @@ SYSCALL_DEFINE4(socketpair, int, family, int, type, int, protocol, | |||
| 1390 | if (err < 0) | 1364 | if (err < 0) |
| 1391 | goto out_release_both; | 1365 | goto out_release_both; |
| 1392 | 1366 | ||
| 1393 | fd1 = sock_alloc_fd(&newfile1, flags & O_CLOEXEC); | 1367 | fd1 = sock_alloc_file(sock1, &newfile1, flags); |
| 1394 | if (unlikely(fd1 < 0)) { | 1368 | if (unlikely(fd1 < 0)) { |
| 1395 | err = fd1; | 1369 | err = fd1; |
| 1396 | goto out_release_both; | 1370 | goto out_release_both; |
| 1397 | } | 1371 | } |
| 1398 | 1372 | ||
| 1399 | fd2 = sock_alloc_fd(&newfile2, flags & O_CLOEXEC); | 1373 | fd2 = sock_alloc_file(sock2, &newfile2, flags); |
| 1400 | if (unlikely(fd2 < 0)) { | 1374 | if (unlikely(fd2 < 0)) { |
| 1401 | err = fd2; | 1375 | err = fd2; |
| 1402 | put_filp(newfile1); | ||
| 1403 | put_unused_fd(fd1); | ||
| 1404 | goto out_release_both; | ||
| 1405 | } | ||
| 1406 | |||
| 1407 | err = sock_attach_fd(sock1, newfile1, flags & O_NONBLOCK); | ||
| 1408 | if (unlikely(err < 0)) { | ||
| 1409 | goto out_fd2; | ||
| 1410 | } | ||
| 1411 | |||
| 1412 | err = sock_attach_fd(sock2, newfile2, flags & O_NONBLOCK); | ||
| 1413 | if (unlikely(err < 0)) { | ||
| 1414 | fput(newfile1); | 1376 | fput(newfile1); |
| 1415 | goto out_fd1; | 1377 | put_unused_fd(fd1); |
| 1378 | sock_release(sock2); | ||
| 1379 | goto out; | ||
| 1416 | } | 1380 | } |
| 1417 | 1381 | ||
| 1418 | audit_fd_pair(fd1, fd2); | 1382 | audit_fd_pair(fd1, fd2); |
| @@ -1438,16 +1402,6 @@ out_release_1: | |||
| 1438 | sock_release(sock1); | 1402 | sock_release(sock1); |
| 1439 | out: | 1403 | out: |
| 1440 | return err; | 1404 | return err; |
| 1441 | |||
| 1442 | out_fd2: | ||
| 1443 | put_filp(newfile1); | ||
| 1444 | sock_release(sock1); | ||
| 1445 | out_fd1: | ||
| 1446 | put_filp(newfile2); | ||
| 1447 | sock_release(sock2); | ||
| 1448 | put_unused_fd(fd1); | ||
| 1449 | put_unused_fd(fd2); | ||
| 1450 | goto out; | ||
| 1451 | } | 1405 | } |
| 1452 | 1406 | ||
| 1453 | /* | 1407 | /* |
| @@ -1551,17 +1505,13 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr, | |||
| 1551 | */ | 1505 | */ |
| 1552 | __module_get(newsock->ops->owner); | 1506 | __module_get(newsock->ops->owner); |
| 1553 | 1507 | ||
| 1554 | newfd = sock_alloc_fd(&newfile, flags & O_CLOEXEC); | 1508 | newfd = sock_alloc_file(newsock, &newfile, flags); |
| 1555 | if (unlikely(newfd < 0)) { | 1509 | if (unlikely(newfd < 0)) { |
| 1556 | err = newfd; | 1510 | err = newfd; |
| 1557 | sock_release(newsock); | 1511 | sock_release(newsock); |
| 1558 | goto out_put; | 1512 | goto out_put; |
| 1559 | } | 1513 | } |
| 1560 | 1514 | ||
| 1561 | err = sock_attach_fd(newsock, newfile, flags & O_NONBLOCK); | ||
| 1562 | if (err < 0) | ||
| 1563 | goto out_fd_simple; | ||
| 1564 | |||
| 1565 | err = security_socket_accept(sock, newsock); | 1515 | err = security_socket_accept(sock, newsock); |
| 1566 | if (err) | 1516 | if (err) |
| 1567 | goto out_fd; | 1517 | goto out_fd; |
| @@ -1591,11 +1541,6 @@ out_put: | |||
| 1591 | fput_light(sock->file, fput_needed); | 1541 | fput_light(sock->file, fput_needed); |
| 1592 | out: | 1542 | out: |
| 1593 | return err; | 1543 | return err; |
| 1594 | out_fd_simple: | ||
| 1595 | sock_release(newsock); | ||
| 1596 | put_filp(newfile); | ||
| 1597 | put_unused_fd(newfd); | ||
| 1598 | goto out_put; | ||
| 1599 | out_fd: | 1544 | out_fd: |
| 1600 | fput(newfile); | 1545 | fput(newfile); |
| 1601 | put_unused_fd(newfd); | 1546 | put_unused_fd(newfd); |
diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c index c7450c8f0a7c..6dcdd2517819 100644 --- a/net/sunrpc/addr.c +++ b/net/sunrpc/addr.c | |||
| @@ -55,16 +55,8 @@ static size_t rpc_ntop6_noscopeid(const struct sockaddr *sap, | |||
| 55 | 55 | ||
| 56 | /* | 56 | /* |
| 57 | * RFC 4291, Section 2.2.1 | 57 | * RFC 4291, Section 2.2.1 |
| 58 | * | ||
| 59 | * To keep the result as short as possible, especially | ||
| 60 | * since we don't shorthand, we don't want leading zeros | ||
| 61 | * in each halfword, so avoid %pI6. | ||
| 62 | */ | 58 | */ |
| 63 | return snprintf(buf, buflen, "%x:%x:%x:%x:%x:%x:%x:%x", | 59 | return snprintf(buf, buflen, "%pI6c", addr); |
| 64 | ntohs(addr->s6_addr16[0]), ntohs(addr->s6_addr16[1]), | ||
| 65 | ntohs(addr->s6_addr16[2]), ntohs(addr->s6_addr16[3]), | ||
| 66 | ntohs(addr->s6_addr16[4]), ntohs(addr->s6_addr16[5]), | ||
| 67 | ntohs(addr->s6_addr16[6]), ntohs(addr->s6_addr16[7])); | ||
| 68 | } | 60 | } |
| 69 | 61 | ||
| 70 | static size_t rpc_ntop6(const struct sockaddr *sap, | 62 | static size_t rpc_ntop6(const struct sockaddr *sap, |
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 7535a7bed2fa..f394fc190a49 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c | |||
| @@ -123,16 +123,19 @@ rpcauth_unhash_cred_locked(struct rpc_cred *cred) | |||
| 123 | clear_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags); | 123 | clear_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | static void | 126 | static int |
| 127 | rpcauth_unhash_cred(struct rpc_cred *cred) | 127 | rpcauth_unhash_cred(struct rpc_cred *cred) |
| 128 | { | 128 | { |
| 129 | spinlock_t *cache_lock; | 129 | spinlock_t *cache_lock; |
| 130 | int ret; | ||
| 130 | 131 | ||
| 131 | cache_lock = &cred->cr_auth->au_credcache->lock; | 132 | cache_lock = &cred->cr_auth->au_credcache->lock; |
| 132 | spin_lock(cache_lock); | 133 | spin_lock(cache_lock); |
| 133 | if (atomic_read(&cred->cr_count) == 0) | 134 | ret = atomic_read(&cred->cr_count) == 0; |
| 135 | if (ret) | ||
| 134 | rpcauth_unhash_cred_locked(cred); | 136 | rpcauth_unhash_cred_locked(cred); |
| 135 | spin_unlock(cache_lock); | 137 | spin_unlock(cache_lock); |
| 138 | return ret; | ||
| 136 | } | 139 | } |
| 137 | 140 | ||
| 138 | /* | 141 | /* |
| @@ -446,31 +449,35 @@ void | |||
| 446 | put_rpccred(struct rpc_cred *cred) | 449 | put_rpccred(struct rpc_cred *cred) |
| 447 | { | 450 | { |
| 448 | /* Fast path for unhashed credentials */ | 451 | /* Fast path for unhashed credentials */ |
| 449 | if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) | 452 | if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) == 0) { |
| 450 | goto need_lock; | 453 | if (atomic_dec_and_test(&cred->cr_count)) |
| 451 | 454 | cred->cr_ops->crdestroy(cred); | |
| 452 | if (!atomic_dec_and_test(&cred->cr_count)) | ||
| 453 | return; | 455 | return; |
| 454 | goto out_destroy; | 456 | } |
| 455 | need_lock: | 457 | |
| 456 | if (!atomic_dec_and_lock(&cred->cr_count, &rpc_credcache_lock)) | 458 | if (!atomic_dec_and_lock(&cred->cr_count, &rpc_credcache_lock)) |
| 457 | return; | 459 | return; |
| 458 | if (!list_empty(&cred->cr_lru)) { | 460 | if (!list_empty(&cred->cr_lru)) { |
| 459 | number_cred_unused--; | 461 | number_cred_unused--; |
| 460 | list_del_init(&cred->cr_lru); | 462 | list_del_init(&cred->cr_lru); |
| 461 | } | 463 | } |
| 462 | if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) == 0) | ||
| 463 | rpcauth_unhash_cred(cred); | ||
| 464 | if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) { | 464 | if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) { |
| 465 | cred->cr_expire = jiffies; | 465 | if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0) { |
| 466 | list_add_tail(&cred->cr_lru, &cred_unused); | 466 | cred->cr_expire = jiffies; |
| 467 | number_cred_unused++; | 467 | list_add_tail(&cred->cr_lru, &cred_unused); |
| 468 | spin_unlock(&rpc_credcache_lock); | 468 | number_cred_unused++; |
| 469 | return; | 469 | goto out_nodestroy; |
| 470 | } | ||
| 471 | if (!rpcauth_unhash_cred(cred)) { | ||
| 472 | /* We were hashed and someone looked us up... */ | ||
| 473 | goto out_nodestroy; | ||
| 474 | } | ||
| 470 | } | 475 | } |
| 471 | spin_unlock(&rpc_credcache_lock); | 476 | spin_unlock(&rpc_credcache_lock); |
| 472 | out_destroy: | ||
| 473 | cred->cr_ops->crdestroy(cred); | 477 | cred->cr_ops->crdestroy(cred); |
| 478 | return; | ||
| 479 | out_nodestroy: | ||
| 480 | spin_unlock(&rpc_credcache_lock); | ||
| 474 | } | 481 | } |
| 475 | EXPORT_SYMBOL_GPL(put_rpccred); | 482 | EXPORT_SYMBOL_GPL(put_rpccred); |
| 476 | 483 | ||
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index fc6a43ccd950..f7a7f8380e38 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c | |||
| @@ -304,7 +304,7 @@ __gss_find_upcall(struct rpc_inode *rpci, uid_t uid) | |||
| 304 | * to that upcall instead of adding the new upcall. | 304 | * to that upcall instead of adding the new upcall. |
| 305 | */ | 305 | */ |
| 306 | static inline struct gss_upcall_msg * | 306 | static inline struct gss_upcall_msg * |
| 307 | gss_add_msg(struct gss_auth *gss_auth, struct gss_upcall_msg *gss_msg) | 307 | gss_add_msg(struct gss_upcall_msg *gss_msg) |
| 308 | { | 308 | { |
| 309 | struct rpc_inode *rpci = gss_msg->inode; | 309 | struct rpc_inode *rpci = gss_msg->inode; |
| 310 | struct inode *inode = &rpci->vfs_inode; | 310 | struct inode *inode = &rpci->vfs_inode; |
| @@ -445,7 +445,7 @@ gss_setup_upcall(struct rpc_clnt *clnt, struct gss_auth *gss_auth, struct rpc_cr | |||
| 445 | gss_new = gss_alloc_msg(gss_auth, uid, clnt, gss_cred->gc_machine_cred); | 445 | gss_new = gss_alloc_msg(gss_auth, uid, clnt, gss_cred->gc_machine_cred); |
| 446 | if (IS_ERR(gss_new)) | 446 | if (IS_ERR(gss_new)) |
| 447 | return gss_new; | 447 | return gss_new; |
| 448 | gss_msg = gss_add_msg(gss_auth, gss_new); | 448 | gss_msg = gss_add_msg(gss_new); |
| 449 | if (gss_msg == gss_new) { | 449 | if (gss_msg == gss_new) { |
| 450 | struct inode *inode = &gss_new->inode->vfs_inode; | 450 | struct inode *inode = &gss_new->inode->vfs_inode; |
| 451 | int res = rpc_queue_upcall(inode, &gss_new->msg); | 451 | int res = rpc_queue_upcall(inode, &gss_new->msg); |
| @@ -485,7 +485,7 @@ gss_refresh_upcall(struct rpc_task *task) | |||
| 485 | dprintk("RPC: %5u gss_refresh_upcall for uid %u\n", task->tk_pid, | 485 | dprintk("RPC: %5u gss_refresh_upcall for uid %u\n", task->tk_pid, |
| 486 | cred->cr_uid); | 486 | cred->cr_uid); |
| 487 | gss_msg = gss_setup_upcall(task->tk_client, gss_auth, cred); | 487 | gss_msg = gss_setup_upcall(task->tk_client, gss_auth, cred); |
| 488 | if (IS_ERR(gss_msg) == -EAGAIN) { | 488 | if (PTR_ERR(gss_msg) == -EAGAIN) { |
| 489 | /* XXX: warning on the first, under the assumption we | 489 | /* XXX: warning on the first, under the assumption we |
| 490 | * shouldn't normally hit this case on a refresh. */ | 490 | * shouldn't normally hit this case on a refresh. */ |
| 491 | warn_gssd(); | 491 | warn_gssd(); |
| @@ -644,7 +644,22 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen) | |||
| 644 | p = gss_fill_context(p, end, ctx, gss_msg->auth->mech); | 644 | p = gss_fill_context(p, end, ctx, gss_msg->auth->mech); |
| 645 | if (IS_ERR(p)) { | 645 | if (IS_ERR(p)) { |
| 646 | err = PTR_ERR(p); | 646 | err = PTR_ERR(p); |
| 647 | gss_msg->msg.errno = (err == -EAGAIN) ? -EAGAIN : -EACCES; | 647 | switch (err) { |
| 648 | case -EACCES: | ||
| 649 | gss_msg->msg.errno = err; | ||
| 650 | err = mlen; | ||
| 651 | break; | ||
| 652 | case -EFAULT: | ||
| 653 | case -ENOMEM: | ||
| 654 | case -EINVAL: | ||
| 655 | case -ENOSYS: | ||
| 656 | gss_msg->msg.errno = -EAGAIN; | ||
| 657 | break; | ||
| 658 | default: | ||
| 659 | printk(KERN_CRIT "%s: bad return from " | ||
| 660 | "gss_fill_context: %zd\n", __func__, err); | ||
| 661 | BUG(); | ||
| 662 | } | ||
| 648 | goto err_release_msg; | 663 | goto err_release_msg; |
| 649 | } | 664 | } |
| 650 | gss_msg->ctx = gss_get_ctx(ctx); | 665 | gss_msg->ctx = gss_get_ctx(ctx); |
diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c index ef45eba22485..2deb0ed72ff4 100644 --- a/net/sunrpc/auth_gss/gss_krb5_mech.c +++ b/net/sunrpc/auth_gss/gss_krb5_mech.c | |||
| @@ -131,8 +131,10 @@ gss_import_sec_context_kerberos(const void *p, | |||
| 131 | struct krb5_ctx *ctx; | 131 | struct krb5_ctx *ctx; |
| 132 | int tmp; | 132 | int tmp; |
| 133 | 133 | ||
| 134 | if (!(ctx = kzalloc(sizeof(*ctx), GFP_NOFS))) | 134 | if (!(ctx = kzalloc(sizeof(*ctx), GFP_NOFS))) { |
| 135 | p = ERR_PTR(-ENOMEM); | ||
| 135 | goto out_err; | 136 | goto out_err; |
| 137 | } | ||
| 136 | 138 | ||
| 137 | p = simple_get_bytes(p, end, &ctx->initiate, sizeof(ctx->initiate)); | 139 | p = simple_get_bytes(p, end, &ctx->initiate, sizeof(ctx->initiate)); |
| 138 | if (IS_ERR(p)) | 140 | if (IS_ERR(p)) |
diff --git a/net/sunrpc/auth_gss/gss_mech_switch.c b/net/sunrpc/auth_gss/gss_mech_switch.c index 6efbb0cd3c7c..76e4c6f4ac3c 100644 --- a/net/sunrpc/auth_gss/gss_mech_switch.c +++ b/net/sunrpc/auth_gss/gss_mech_switch.c | |||
| @@ -252,7 +252,7 @@ gss_import_sec_context(const void *input_token, size_t bufsize, | |||
| 252 | struct gss_ctx **ctx_id) | 252 | struct gss_ctx **ctx_id) |
| 253 | { | 253 | { |
| 254 | if (!(*ctx_id = kzalloc(sizeof(**ctx_id), GFP_KERNEL))) | 254 | if (!(*ctx_id = kzalloc(sizeof(**ctx_id), GFP_KERNEL))) |
| 255 | return GSS_S_FAILURE; | 255 | return -ENOMEM; |
| 256 | (*ctx_id)->mech_type = gss_mech_get(mech); | 256 | (*ctx_id)->mech_type = gss_mech_get(mech); |
| 257 | 257 | ||
| 258 | return mech->gm_ops | 258 | return mech->gm_ops |
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 38829e20500b..154034b675bd 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
| @@ -79,7 +79,7 @@ static void call_connect_status(struct rpc_task *task); | |||
| 79 | 79 | ||
| 80 | static __be32 *rpc_encode_header(struct rpc_task *task); | 80 | static __be32 *rpc_encode_header(struct rpc_task *task); |
| 81 | static __be32 *rpc_verify_header(struct rpc_task *task); | 81 | static __be32 *rpc_verify_header(struct rpc_task *task); |
| 82 | static int rpc_ping(struct rpc_clnt *clnt, int flags); | 82 | static int rpc_ping(struct rpc_clnt *clnt); |
| 83 | 83 | ||
| 84 | static void rpc_register_client(struct rpc_clnt *clnt) | 84 | static void rpc_register_client(struct rpc_clnt *clnt) |
| 85 | { | 85 | { |
| @@ -340,7 +340,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args) | |||
| 340 | return clnt; | 340 | return clnt; |
| 341 | 341 | ||
| 342 | if (!(args->flags & RPC_CLNT_CREATE_NOPING)) { | 342 | if (!(args->flags & RPC_CLNT_CREATE_NOPING)) { |
| 343 | int err = rpc_ping(clnt, RPC_TASK_SOFT); | 343 | int err = rpc_ping(clnt); |
| 344 | if (err != 0) { | 344 | if (err != 0) { |
| 345 | rpc_shutdown_client(clnt); | 345 | rpc_shutdown_client(clnt); |
| 346 | return ERR_PTR(err); | 346 | return ERR_PTR(err); |
| @@ -528,7 +528,7 @@ struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *old, | |||
| 528 | clnt->cl_prog = program->number; | 528 | clnt->cl_prog = program->number; |
| 529 | clnt->cl_vers = version->number; | 529 | clnt->cl_vers = version->number; |
| 530 | clnt->cl_stats = program->stats; | 530 | clnt->cl_stats = program->stats; |
| 531 | err = rpc_ping(clnt, RPC_TASK_SOFT); | 531 | err = rpc_ping(clnt); |
| 532 | if (err != 0) { | 532 | if (err != 0) { |
| 533 | rpc_shutdown_client(clnt); | 533 | rpc_shutdown_client(clnt); |
| 534 | clnt = ERR_PTR(err); | 534 | clnt = ERR_PTR(err); |
| @@ -1060,7 +1060,7 @@ call_bind_status(struct rpc_task *task) | |||
| 1060 | goto retry_timeout; | 1060 | goto retry_timeout; |
| 1061 | case -EPFNOSUPPORT: | 1061 | case -EPFNOSUPPORT: |
| 1062 | /* server doesn't support any rpcbind version we know of */ | 1062 | /* server doesn't support any rpcbind version we know of */ |
| 1063 | dprintk("RPC: %5u remote rpcbind service unavailable\n", | 1063 | dprintk("RPC: %5u unrecognized remote rpcbind service\n", |
| 1064 | task->tk_pid); | 1064 | task->tk_pid); |
| 1065 | break; | 1065 | break; |
| 1066 | case -EPROTONOSUPPORT: | 1066 | case -EPROTONOSUPPORT: |
| @@ -1069,6 +1069,21 @@ call_bind_status(struct rpc_task *task) | |||
| 1069 | task->tk_status = 0; | 1069 | task->tk_status = 0; |
| 1070 | task->tk_action = call_bind; | 1070 | task->tk_action = call_bind; |
| 1071 | return; | 1071 | return; |
| 1072 | case -ECONNREFUSED: /* connection problems */ | ||
| 1073 | case -ECONNRESET: | ||
| 1074 | case -ENOTCONN: | ||
| 1075 | case -EHOSTDOWN: | ||
| 1076 | case -EHOSTUNREACH: | ||
| 1077 | case -ENETUNREACH: | ||
| 1078 | case -EPIPE: | ||
| 1079 | dprintk("RPC: %5u remote rpcbind unreachable: %d\n", | ||
| 1080 | task->tk_pid, task->tk_status); | ||
| 1081 | if (!RPC_IS_SOFTCONN(task)) { | ||
| 1082 | rpc_delay(task, 5*HZ); | ||
| 1083 | goto retry_timeout; | ||
| 1084 | } | ||
| 1085 | status = task->tk_status; | ||
| 1086 | break; | ||
| 1072 | default: | 1087 | default: |
| 1073 | dprintk("RPC: %5u unrecognized rpcbind error (%d)\n", | 1088 | dprintk("RPC: %5u unrecognized rpcbind error (%d)\n", |
| 1074 | task->tk_pid, -task->tk_status); | 1089 | task->tk_pid, -task->tk_status); |
| @@ -1180,11 +1195,25 @@ static void | |||
| 1180 | call_transmit_status(struct rpc_task *task) | 1195 | call_transmit_status(struct rpc_task *task) |
| 1181 | { | 1196 | { |
| 1182 | task->tk_action = call_status; | 1197 | task->tk_action = call_status; |
| 1198 | |||
| 1199 | /* | ||
| 1200 | * Common case: success. Force the compiler to put this | ||
| 1201 | * test first. | ||
| 1202 | */ | ||
| 1203 | if (task->tk_status == 0) { | ||
| 1204 | xprt_end_transmit(task); | ||
| 1205 | rpc_task_force_reencode(task); | ||
| 1206 | return; | ||
| 1207 | } | ||
| 1208 | |||
| 1183 | switch (task->tk_status) { | 1209 | switch (task->tk_status) { |
| 1184 | case -EAGAIN: | 1210 | case -EAGAIN: |
| 1185 | break; | 1211 | break; |
| 1186 | default: | 1212 | default: |
| 1213 | dprint_status(task); | ||
| 1187 | xprt_end_transmit(task); | 1214 | xprt_end_transmit(task); |
| 1215 | rpc_task_force_reencode(task); | ||
| 1216 | break; | ||
| 1188 | /* | 1217 | /* |
| 1189 | * Special cases: if we've been waiting on the | 1218 | * Special cases: if we've been waiting on the |
| 1190 | * socket's write_space() callback, or if the | 1219 | * socket's write_space() callback, or if the |
| @@ -1192,11 +1221,16 @@ call_transmit_status(struct rpc_task *task) | |||
| 1192 | * then hold onto the transport lock. | 1221 | * then hold onto the transport lock. |
| 1193 | */ | 1222 | */ |
| 1194 | case -ECONNREFUSED: | 1223 | case -ECONNREFUSED: |
| 1195 | case -ECONNRESET: | ||
| 1196 | case -ENOTCONN: | ||
| 1197 | case -EHOSTDOWN: | 1224 | case -EHOSTDOWN: |
| 1198 | case -EHOSTUNREACH: | 1225 | case -EHOSTUNREACH: |
| 1199 | case -ENETUNREACH: | 1226 | case -ENETUNREACH: |
| 1227 | if (RPC_IS_SOFTCONN(task)) { | ||
| 1228 | xprt_end_transmit(task); | ||
| 1229 | rpc_exit(task, task->tk_status); | ||
| 1230 | break; | ||
| 1231 | } | ||
| 1232 | case -ECONNRESET: | ||
| 1233 | case -ENOTCONN: | ||
| 1200 | case -EPIPE: | 1234 | case -EPIPE: |
| 1201 | rpc_task_force_reencode(task); | 1235 | rpc_task_force_reencode(task); |
| 1202 | } | 1236 | } |
| @@ -1346,6 +1380,10 @@ call_timeout(struct rpc_task *task) | |||
| 1346 | dprintk("RPC: %5u call_timeout (major)\n", task->tk_pid); | 1380 | dprintk("RPC: %5u call_timeout (major)\n", task->tk_pid); |
| 1347 | task->tk_timeouts++; | 1381 | task->tk_timeouts++; |
| 1348 | 1382 | ||
| 1383 | if (RPC_IS_SOFTCONN(task)) { | ||
| 1384 | rpc_exit(task, -ETIMEDOUT); | ||
| 1385 | return; | ||
| 1386 | } | ||
| 1349 | if (RPC_IS_SOFT(task)) { | 1387 | if (RPC_IS_SOFT(task)) { |
| 1350 | if (clnt->cl_chatty) | 1388 | if (clnt->cl_chatty) |
| 1351 | printk(KERN_NOTICE "%s: server %s not responding, timed out\n", | 1389 | printk(KERN_NOTICE "%s: server %s not responding, timed out\n", |
| @@ -1675,14 +1713,14 @@ static struct rpc_procinfo rpcproc_null = { | |||
| 1675 | .p_decode = rpcproc_decode_null, | 1713 | .p_decode = rpcproc_decode_null, |
| 1676 | }; | 1714 | }; |
| 1677 | 1715 | ||
| 1678 | static int rpc_ping(struct rpc_clnt *clnt, int flags) | 1716 | static int rpc_ping(struct rpc_clnt *clnt) |
| 1679 | { | 1717 | { |
| 1680 | struct rpc_message msg = { | 1718 | struct rpc_message msg = { |
| 1681 | .rpc_proc = &rpcproc_null, | 1719 | .rpc_proc = &rpcproc_null, |
| 1682 | }; | 1720 | }; |
| 1683 | int err; | 1721 | int err; |
| 1684 | msg.rpc_cred = authnull_ops.lookup_cred(NULL, NULL, 0); | 1722 | msg.rpc_cred = authnull_ops.lookup_cred(NULL, NULL, 0); |
| 1685 | err = rpc_call_sync(clnt, &msg, flags); | 1723 | err = rpc_call_sync(clnt, &msg, RPC_TASK_SOFT | RPC_TASK_SOFTCONN); |
| 1686 | put_rpccred(msg.rpc_cred); | 1724 | put_rpccred(msg.rpc_cred); |
| 1687 | return err; | 1725 | return err; |
| 1688 | } | 1726 | } |
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c index 830faf4d9997..3e3772d8eb92 100644 --- a/net/sunrpc/rpcb_clnt.c +++ b/net/sunrpc/rpcb_clnt.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/in6.h> | 20 | #include <linux/in6.h> |
| 21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
| 22 | #include <linux/errno.h> | 22 | #include <linux/errno.h> |
| 23 | #include <linux/mutex.h> | ||
| 23 | #include <net/ipv6.h> | 24 | #include <net/ipv6.h> |
| 24 | 25 | ||
| 25 | #include <linux/sunrpc/clnt.h> | 26 | #include <linux/sunrpc/clnt.h> |
| @@ -110,6 +111,9 @@ static void rpcb_getport_done(struct rpc_task *, void *); | |||
| 110 | static void rpcb_map_release(void *data); | 111 | static void rpcb_map_release(void *data); |
| 111 | static struct rpc_program rpcb_program; | 112 | static struct rpc_program rpcb_program; |
| 112 | 113 | ||
| 114 | static struct rpc_clnt * rpcb_local_clnt; | ||
| 115 | static struct rpc_clnt * rpcb_local_clnt4; | ||
| 116 | |||
| 113 | struct rpcbind_args { | 117 | struct rpcbind_args { |
| 114 | struct rpc_xprt * r_xprt; | 118 | struct rpc_xprt * r_xprt; |
| 115 | 119 | ||
| @@ -163,21 +167,60 @@ static const struct sockaddr_in rpcb_inaddr_loopback = { | |||
| 163 | .sin_port = htons(RPCBIND_PORT), | 167 | .sin_port = htons(RPCBIND_PORT), |
| 164 | }; | 168 | }; |
| 165 | 169 | ||
| 166 | static struct rpc_clnt *rpcb_create_local(struct sockaddr *addr, | 170 | static DEFINE_MUTEX(rpcb_create_local_mutex); |
| 167 | size_t addrlen, u32 version) | 171 | |
| 172 | /* | ||
| 173 | * Returns zero on success, otherwise a negative errno value | ||
| 174 | * is returned. | ||
| 175 | */ | ||
| 176 | static int rpcb_create_local(void) | ||
| 168 | { | 177 | { |
| 169 | struct rpc_create_args args = { | 178 | struct rpc_create_args args = { |
| 170 | .protocol = XPRT_TRANSPORT_UDP, | 179 | .protocol = XPRT_TRANSPORT_TCP, |
| 171 | .address = addr, | 180 | .address = (struct sockaddr *)&rpcb_inaddr_loopback, |
| 172 | .addrsize = addrlen, | 181 | .addrsize = sizeof(rpcb_inaddr_loopback), |
| 173 | .servername = "localhost", | 182 | .servername = "localhost", |
| 174 | .program = &rpcb_program, | 183 | .program = &rpcb_program, |
| 175 | .version = version, | 184 | .version = RPCBVERS_2, |
| 176 | .authflavor = RPC_AUTH_UNIX, | 185 | .authflavor = RPC_AUTH_UNIX, |
| 177 | .flags = RPC_CLNT_CREATE_NOPING, | 186 | .flags = RPC_CLNT_CREATE_NOPING, |
| 178 | }; | 187 | }; |
| 188 | struct rpc_clnt *clnt, *clnt4; | ||
| 189 | int result = 0; | ||
| 190 | |||
| 191 | if (rpcb_local_clnt) | ||
| 192 | return result; | ||
| 193 | |||
| 194 | mutex_lock(&rpcb_create_local_mutex); | ||
| 195 | if (rpcb_local_clnt) | ||
| 196 | goto out; | ||
| 197 | |||
| 198 | clnt = rpc_create(&args); | ||
| 199 | if (IS_ERR(clnt)) { | ||
| 200 | dprintk("RPC: failed to create local rpcbind " | ||
| 201 | "client (errno %ld).\n", PTR_ERR(clnt)); | ||
| 202 | result = -PTR_ERR(clnt); | ||
| 203 | goto out; | ||
| 204 | } | ||
| 179 | 205 | ||
| 180 | return rpc_create(&args); | 206 | /* |
| 207 | * This results in an RPC ping. On systems running portmapper, | ||
| 208 | * the v4 ping will fail. Proceed anyway, but disallow rpcb | ||
| 209 | * v4 upcalls. | ||
| 210 | */ | ||
| 211 | clnt4 = rpc_bind_new_program(clnt, &rpcb_program, RPCBVERS_4); | ||
| 212 | if (IS_ERR(clnt4)) { | ||
| 213 | dprintk("RPC: failed to create local rpcbind v4 " | ||
| 214 | "cleint (errno %ld).\n", PTR_ERR(clnt4)); | ||
| 215 | clnt4 = NULL; | ||
| 216 | } | ||
| 217 | |||
| 218 | rpcb_local_clnt = clnt; | ||
| 219 | rpcb_local_clnt4 = clnt4; | ||
| 220 | |||
| 221 | out: | ||
| 222 | mutex_unlock(&rpcb_create_local_mutex); | ||
| 223 | return result; | ||
| 181 | } | 224 | } |
| 182 | 225 | ||
| 183 | static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, | 226 | static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, |
| @@ -209,22 +252,13 @@ static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, | |||
| 209 | return rpc_create(&args); | 252 | return rpc_create(&args); |
| 210 | } | 253 | } |
| 211 | 254 | ||
| 212 | static int rpcb_register_call(const u32 version, struct rpc_message *msg) | 255 | static int rpcb_register_call(struct rpc_clnt *clnt, struct rpc_message *msg) |
| 213 | { | 256 | { |
| 214 | struct sockaddr *addr = (struct sockaddr *)&rpcb_inaddr_loopback; | ||
| 215 | size_t addrlen = sizeof(rpcb_inaddr_loopback); | ||
| 216 | struct rpc_clnt *rpcb_clnt; | ||
| 217 | int result, error = 0; | 257 | int result, error = 0; |
| 218 | 258 | ||
| 219 | msg->rpc_resp = &result; | 259 | msg->rpc_resp = &result; |
| 220 | 260 | ||
| 221 | rpcb_clnt = rpcb_create_local(addr, addrlen, version); | 261 | error = rpc_call_sync(clnt, msg, RPC_TASK_SOFTCONN); |
| 222 | if (!IS_ERR(rpcb_clnt)) { | ||
| 223 | error = rpc_call_sync(rpcb_clnt, msg, 0); | ||
| 224 | rpc_shutdown_client(rpcb_clnt); | ||
| 225 | } else | ||
| 226 | error = PTR_ERR(rpcb_clnt); | ||
| 227 | |||
| 228 | if (error < 0) { | 262 | if (error < 0) { |
| 229 | dprintk("RPC: failed to contact local rpcbind " | 263 | dprintk("RPC: failed to contact local rpcbind " |
| 230 | "server (errno %d).\n", -error); | 264 | "server (errno %d).\n", -error); |
| @@ -279,6 +313,11 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port) | |||
| 279 | struct rpc_message msg = { | 313 | struct rpc_message msg = { |
| 280 | .rpc_argp = &map, | 314 | .rpc_argp = &map, |
| 281 | }; | 315 | }; |
| 316 | int error; | ||
| 317 | |||
| 318 | error = rpcb_create_local(); | ||
| 319 | if (error) | ||
| 320 | return error; | ||
| 282 | 321 | ||
| 283 | dprintk("RPC: %sregistering (%u, %u, %d, %u) with local " | 322 | dprintk("RPC: %sregistering (%u, %u, %d, %u) with local " |
| 284 | "rpcbind\n", (port ? "" : "un"), | 323 | "rpcbind\n", (port ? "" : "un"), |
| @@ -288,7 +327,7 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port) | |||
| 288 | if (port) | 327 | if (port) |
| 289 | msg.rpc_proc = &rpcb_procedures2[RPCBPROC_SET]; | 328 | msg.rpc_proc = &rpcb_procedures2[RPCBPROC_SET]; |
| 290 | 329 | ||
| 291 | return rpcb_register_call(RPCBVERS_2, &msg); | 330 | return rpcb_register_call(rpcb_local_clnt, &msg); |
| 292 | } | 331 | } |
| 293 | 332 | ||
| 294 | /* | 333 | /* |
| @@ -313,7 +352,7 @@ static int rpcb_register_inet4(const struct sockaddr *sap, | |||
| 313 | if (port) | 352 | if (port) |
| 314 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; | 353 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; |
| 315 | 354 | ||
| 316 | result = rpcb_register_call(RPCBVERS_4, msg); | 355 | result = rpcb_register_call(rpcb_local_clnt4, msg); |
| 317 | kfree(map->r_addr); | 356 | kfree(map->r_addr); |
| 318 | return result; | 357 | return result; |
| 319 | } | 358 | } |
| @@ -340,7 +379,7 @@ static int rpcb_register_inet6(const struct sockaddr *sap, | |||
| 340 | if (port) | 379 | if (port) |
| 341 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; | 380 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; |
| 342 | 381 | ||
| 343 | result = rpcb_register_call(RPCBVERS_4, msg); | 382 | result = rpcb_register_call(rpcb_local_clnt4, msg); |
| 344 | kfree(map->r_addr); | 383 | kfree(map->r_addr); |
| 345 | return result; | 384 | return result; |
| 346 | } | 385 | } |
| @@ -356,7 +395,7 @@ static int rpcb_unregister_all_protofamilies(struct rpc_message *msg) | |||
| 356 | map->r_addr = ""; | 395 | map->r_addr = ""; |
| 357 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET]; | 396 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET]; |
| 358 | 397 | ||
| 359 | return rpcb_register_call(RPCBVERS_4, msg); | 398 | return rpcb_register_call(rpcb_local_clnt4, msg); |
| 360 | } | 399 | } |
| 361 | 400 | ||
| 362 | /** | 401 | /** |
| @@ -414,6 +453,13 @@ int rpcb_v4_register(const u32 program, const u32 version, | |||
| 414 | struct rpc_message msg = { | 453 | struct rpc_message msg = { |
| 415 | .rpc_argp = &map, | 454 | .rpc_argp = &map, |
| 416 | }; | 455 | }; |
| 456 | int error; | ||
| 457 | |||
| 458 | error = rpcb_create_local(); | ||
| 459 | if (error) | ||
| 460 | return error; | ||
| 461 | if (rpcb_local_clnt4 == NULL) | ||
| 462 | return -EPROTONOSUPPORT; | ||
| 417 | 463 | ||
| 418 | if (address == NULL) | 464 | if (address == NULL) |
| 419 | return rpcb_unregister_all_protofamilies(&msg); | 465 | return rpcb_unregister_all_protofamilies(&msg); |
| @@ -491,7 +537,7 @@ static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt, struct rpcbi | |||
| 491 | .rpc_message = &msg, | 537 | .rpc_message = &msg, |
| 492 | .callback_ops = &rpcb_getport_ops, | 538 | .callback_ops = &rpcb_getport_ops, |
| 493 | .callback_data = map, | 539 | .callback_data = map, |
| 494 | .flags = RPC_TASK_ASYNC, | 540 | .flags = RPC_TASK_ASYNC | RPC_TASK_SOFTCONN, |
| 495 | }; | 541 | }; |
| 496 | 542 | ||
| 497 | return rpc_run_task(&task_setup_data); | 543 | return rpc_run_task(&task_setup_data); |
| @@ -1027,3 +1073,15 @@ static struct rpc_program rpcb_program = { | |||
| 1027 | .version = rpcb_version, | 1073 | .version = rpcb_version, |
| 1028 | .stats = &rpcb_stats, | 1074 | .stats = &rpcb_stats, |
| 1029 | }; | 1075 | }; |
| 1076 | |||
| 1077 | /** | ||
| 1078 | * cleanup_rpcb_clnt - remove xprtsock's sysctls, unregister | ||
| 1079 | * | ||
| 1080 | */ | ||
| 1081 | void cleanup_rpcb_clnt(void) | ||
| 1082 | { | ||
| 1083 | if (rpcb_local_clnt4) | ||
| 1084 | rpc_shutdown_client(rpcb_local_clnt4); | ||
| 1085 | if (rpcb_local_clnt) | ||
| 1086 | rpc_shutdown_client(rpcb_local_clnt); | ||
| 1087 | } | ||
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index cef74ba0666c..aae6907fd546 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c | |||
| @@ -210,6 +210,7 @@ void rpc_init_priority_wait_queue(struct rpc_wait_queue *queue, const char *qnam | |||
| 210 | { | 210 | { |
| 211 | __rpc_init_priority_wait_queue(queue, qname, RPC_NR_PRIORITY); | 211 | __rpc_init_priority_wait_queue(queue, qname, RPC_NR_PRIORITY); |
| 212 | } | 212 | } |
| 213 | EXPORT_SYMBOL_GPL(rpc_init_priority_wait_queue); | ||
| 213 | 214 | ||
| 214 | void rpc_init_wait_queue(struct rpc_wait_queue *queue, const char *qname) | 215 | void rpc_init_wait_queue(struct rpc_wait_queue *queue, const char *qname) |
| 215 | { | 216 | { |
| @@ -385,6 +386,20 @@ static void rpc_wake_up_task_queue_locked(struct rpc_wait_queue *queue, struct r | |||
| 385 | } | 386 | } |
| 386 | 387 | ||
| 387 | /* | 388 | /* |
| 389 | * Tests whether rpc queue is empty | ||
| 390 | */ | ||
| 391 | int rpc_queue_empty(struct rpc_wait_queue *queue) | ||
| 392 | { | ||
| 393 | int res; | ||
| 394 | |||
| 395 | spin_lock_bh(&queue->lock); | ||
| 396 | res = queue->qlen; | ||
| 397 | spin_unlock_bh(&queue->lock); | ||
| 398 | return (res == 0); | ||
| 399 | } | ||
| 400 | EXPORT_SYMBOL_GPL(rpc_queue_empty); | ||
| 401 | |||
| 402 | /* | ||
| 388 | * Wake up a task on a specific queue | 403 | * Wake up a task on a specific queue |
| 389 | */ | 404 | */ |
| 390 | void rpc_wake_up_queued_task(struct rpc_wait_queue *queue, struct rpc_task *task) | 405 | void rpc_wake_up_queued_task(struct rpc_wait_queue *queue, struct rpc_task *task) |
diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c index 8cce92189019..f438347d817b 100644 --- a/net/sunrpc/sunrpc_syms.c +++ b/net/sunrpc/sunrpc_syms.c | |||
| @@ -24,6 +24,8 @@ | |||
| 24 | 24 | ||
| 25 | extern struct cache_detail ip_map_cache, unix_gid_cache; | 25 | extern struct cache_detail ip_map_cache, unix_gid_cache; |
| 26 | 26 | ||
| 27 | extern void cleanup_rpcb_clnt(void); | ||
| 28 | |||
| 27 | static int __init | 29 | static int __init |
| 28 | init_sunrpc(void) | 30 | init_sunrpc(void) |
| 29 | { | 31 | { |
| @@ -53,6 +55,7 @@ out: | |||
| 53 | static void __exit | 55 | static void __exit |
| 54 | cleanup_sunrpc(void) | 56 | cleanup_sunrpc(void) |
| 55 | { | 57 | { |
| 58 | cleanup_rpcb_clnt(); | ||
| 56 | rpcauth_remove_module(); | 59 | rpcauth_remove_module(); |
| 57 | cleanup_socket_xprt(); | 60 | cleanup_socket_xprt(); |
| 58 | svc_cleanup_xprt_sock(); | 61 | svc_cleanup_xprt_sock(); |
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index b845e2293dfe..7d1f9e928f69 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c | |||
| @@ -16,8 +16,6 @@ | |||
| 16 | 16 | ||
| 17 | #define RPCDBG_FACILITY RPCDBG_SVCXPRT | 17 | #define RPCDBG_FACILITY RPCDBG_SVCXPRT |
| 18 | 18 | ||
| 19 | #define SVC_MAX_WAKING 5 | ||
| 20 | |||
| 21 | static struct svc_deferred_req *svc_deferred_dequeue(struct svc_xprt *xprt); | 19 | static struct svc_deferred_req *svc_deferred_dequeue(struct svc_xprt *xprt); |
| 22 | static int svc_deferred_recv(struct svc_rqst *rqstp); | 20 | static int svc_deferred_recv(struct svc_rqst *rqstp); |
| 23 | static struct cache_deferred_req *svc_defer(struct cache_req *req); | 21 | static struct cache_deferred_req *svc_defer(struct cache_req *req); |
| @@ -306,7 +304,6 @@ void svc_xprt_enqueue(struct svc_xprt *xprt) | |||
| 306 | struct svc_pool *pool; | 304 | struct svc_pool *pool; |
| 307 | struct svc_rqst *rqstp; | 305 | struct svc_rqst *rqstp; |
| 308 | int cpu; | 306 | int cpu; |
| 309 | int thread_avail; | ||
| 310 | 307 | ||
| 311 | if (!(xprt->xpt_flags & | 308 | if (!(xprt->xpt_flags & |
| 312 | ((1<<XPT_CONN)|(1<<XPT_DATA)|(1<<XPT_CLOSE)|(1<<XPT_DEFERRED)))) | 309 | ((1<<XPT_CONN)|(1<<XPT_DATA)|(1<<XPT_CLOSE)|(1<<XPT_DEFERRED)))) |
| @@ -318,6 +315,12 @@ void svc_xprt_enqueue(struct svc_xprt *xprt) | |||
| 318 | 315 | ||
| 319 | spin_lock_bh(&pool->sp_lock); | 316 | spin_lock_bh(&pool->sp_lock); |
| 320 | 317 | ||
| 318 | if (!list_empty(&pool->sp_threads) && | ||
| 319 | !list_empty(&pool->sp_sockets)) | ||
| 320 | printk(KERN_ERR | ||
| 321 | "svc_xprt_enqueue: " | ||
| 322 | "threads and transports both waiting??\n"); | ||
| 323 | |||
| 321 | if (test_bit(XPT_DEAD, &xprt->xpt_flags)) { | 324 | if (test_bit(XPT_DEAD, &xprt->xpt_flags)) { |
| 322 | /* Don't enqueue dead transports */ | 325 | /* Don't enqueue dead transports */ |
| 323 | dprintk("svc: transport %p is dead, not enqueued\n", xprt); | 326 | dprintk("svc: transport %p is dead, not enqueued\n", xprt); |
| @@ -358,15 +361,7 @@ void svc_xprt_enqueue(struct svc_xprt *xprt) | |||
| 358 | } | 361 | } |
| 359 | 362 | ||
| 360 | process: | 363 | process: |
| 361 | /* Work out whether threads are available */ | 364 | if (!list_empty(&pool->sp_threads)) { |
| 362 | thread_avail = !list_empty(&pool->sp_threads); /* threads are asleep */ | ||
| 363 | if (pool->sp_nwaking >= SVC_MAX_WAKING) { | ||
| 364 | /* too many threads are runnable and trying to wake up */ | ||
| 365 | thread_avail = 0; | ||
| 366 | pool->sp_stats.overloads_avoided++; | ||
| 367 | } | ||
| 368 | |||
| 369 | if (thread_avail) { | ||
| 370 | rqstp = list_entry(pool->sp_threads.next, | 365 | rqstp = list_entry(pool->sp_threads.next, |
| 371 | struct svc_rqst, | 366 | struct svc_rqst, |
| 372 | rq_list); | 367 | rq_list); |
| @@ -381,8 +376,6 @@ void svc_xprt_enqueue(struct svc_xprt *xprt) | |||
| 381 | svc_xprt_get(xprt); | 376 | svc_xprt_get(xprt); |
| 382 | rqstp->rq_reserved = serv->sv_max_mesg; | 377 | rqstp->rq_reserved = serv->sv_max_mesg; |
| 383 | atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved); | 378 | atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved); |
| 384 | rqstp->rq_waking = 1; | ||
| 385 | pool->sp_nwaking++; | ||
| 386 | pool->sp_stats.threads_woken++; | 379 | pool->sp_stats.threads_woken++; |
| 387 | BUG_ON(xprt->xpt_pool != pool); | 380 | BUG_ON(xprt->xpt_pool != pool); |
| 388 | wake_up(&rqstp->rq_wait); | 381 | wake_up(&rqstp->rq_wait); |
| @@ -651,11 +644,6 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) | |||
| 651 | return -EINTR; | 644 | return -EINTR; |
| 652 | 645 | ||
| 653 | spin_lock_bh(&pool->sp_lock); | 646 | spin_lock_bh(&pool->sp_lock); |
| 654 | if (rqstp->rq_waking) { | ||
| 655 | rqstp->rq_waking = 0; | ||
| 656 | pool->sp_nwaking--; | ||
| 657 | BUG_ON(pool->sp_nwaking < 0); | ||
| 658 | } | ||
| 659 | xprt = svc_xprt_dequeue(pool); | 647 | xprt = svc_xprt_dequeue(pool); |
| 660 | if (xprt) { | 648 | if (xprt) { |
| 661 | rqstp->rq_xprt = xprt; | 649 | rqstp->rq_xprt = xprt; |
| @@ -711,7 +699,8 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) | |||
| 711 | spin_unlock_bh(&pool->sp_lock); | 699 | spin_unlock_bh(&pool->sp_lock); |
| 712 | 700 | ||
| 713 | len = 0; | 701 | len = 0; |
| 714 | if (test_bit(XPT_LISTENER, &xprt->xpt_flags)) { | 702 | if (test_bit(XPT_LISTENER, &xprt->xpt_flags) && |
| 703 | !test_bit(XPT_CLOSE, &xprt->xpt_flags)) { | ||
| 715 | struct svc_xprt *newxpt; | 704 | struct svc_xprt *newxpt; |
| 716 | newxpt = xprt->xpt_ops->xpo_accept(xprt); | 705 | newxpt = xprt->xpt_ops->xpo_accept(xprt); |
| 717 | if (newxpt) { | 706 | if (newxpt) { |
| @@ -1204,16 +1193,15 @@ static int svc_pool_stats_show(struct seq_file *m, void *p) | |||
| 1204 | struct svc_pool *pool = p; | 1193 | struct svc_pool *pool = p; |
| 1205 | 1194 | ||
| 1206 | if (p == SEQ_START_TOKEN) { | 1195 | if (p == SEQ_START_TOKEN) { |
| 1207 | seq_puts(m, "# pool packets-arrived sockets-enqueued threads-woken overloads-avoided threads-timedout\n"); | 1196 | seq_puts(m, "# pool packets-arrived sockets-enqueued threads-woken threads-timedout\n"); |
| 1208 | return 0; | 1197 | return 0; |
| 1209 | } | 1198 | } |
| 1210 | 1199 | ||
| 1211 | seq_printf(m, "%u %lu %lu %lu %lu %lu\n", | 1200 | seq_printf(m, "%u %lu %lu %lu %lu\n", |
| 1212 | pool->sp_id, | 1201 | pool->sp_id, |
| 1213 | pool->sp_stats.packets, | 1202 | pool->sp_stats.packets, |
| 1214 | pool->sp_stats.sockets_queued, | 1203 | pool->sp_stats.sockets_queued, |
| 1215 | pool->sp_stats.threads_woken, | 1204 | pool->sp_stats.threads_woken, |
| 1216 | pool->sp_stats.overloads_avoided, | ||
| 1217 | pool->sp_stats.threads_timedout); | 1205 | pool->sp_stats.threads_timedout); |
| 1218 | 1206 | ||
| 1219 | return 0; | 1207 | return 0; |
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c index 4a8f6558718a..d8c041114497 100644 --- a/net/sunrpc/svcauth_unix.c +++ b/net/sunrpc/svcauth_unix.c | |||
| @@ -655,23 +655,25 @@ static struct unix_gid *unix_gid_lookup(uid_t uid) | |||
| 655 | return NULL; | 655 | return NULL; |
| 656 | } | 656 | } |
| 657 | 657 | ||
| 658 | static int unix_gid_find(uid_t uid, struct group_info **gip, | 658 | static struct group_info *unix_gid_find(uid_t uid, struct svc_rqst *rqstp) |
| 659 | struct svc_rqst *rqstp) | ||
| 660 | { | 659 | { |
| 661 | struct unix_gid *ug = unix_gid_lookup(uid); | 660 | struct unix_gid *ug; |
| 661 | struct group_info *gi; | ||
| 662 | int ret; | ||
| 663 | |||
| 664 | ug = unix_gid_lookup(uid); | ||
| 662 | if (!ug) | 665 | if (!ug) |
| 663 | return -EAGAIN; | 666 | return ERR_PTR(-EAGAIN); |
| 664 | switch (cache_check(&unix_gid_cache, &ug->h, &rqstp->rq_chandle)) { | 667 | ret = cache_check(&unix_gid_cache, &ug->h, &rqstp->rq_chandle); |
| 668 | switch (ret) { | ||
| 665 | case -ENOENT: | 669 | case -ENOENT: |
| 666 | *gip = NULL; | 670 | return ERR_PTR(-ENOENT); |
| 667 | return 0; | ||
| 668 | case 0: | 671 | case 0: |
| 669 | *gip = ug->gi; | 672 | gi = get_group_info(ug->gi); |
| 670 | get_group_info(*gip); | ||
| 671 | cache_put(&ug->h, &unix_gid_cache); | 673 | cache_put(&ug->h, &unix_gid_cache); |
| 672 | return 0; | 674 | return gi; |
| 673 | default: | 675 | default: |
| 674 | return -EAGAIN; | 676 | return ERR_PTR(-EAGAIN); |
| 675 | } | 677 | } |
| 676 | } | 678 | } |
| 677 | 679 | ||
| @@ -681,6 +683,8 @@ svcauth_unix_set_client(struct svc_rqst *rqstp) | |||
| 681 | struct sockaddr_in *sin; | 683 | struct sockaddr_in *sin; |
| 682 | struct sockaddr_in6 *sin6, sin6_storage; | 684 | struct sockaddr_in6 *sin6, sin6_storage; |
| 683 | struct ip_map *ipm; | 685 | struct ip_map *ipm; |
| 686 | struct group_info *gi; | ||
| 687 | struct svc_cred *cred = &rqstp->rq_cred; | ||
| 684 | 688 | ||
| 685 | switch (rqstp->rq_addr.ss_family) { | 689 | switch (rqstp->rq_addr.ss_family) { |
| 686 | case AF_INET: | 690 | case AF_INET: |
| @@ -721,6 +725,17 @@ svcauth_unix_set_client(struct svc_rqst *rqstp) | |||
| 721 | ip_map_cached_put(rqstp, ipm); | 725 | ip_map_cached_put(rqstp, ipm); |
| 722 | break; | 726 | break; |
| 723 | } | 727 | } |
| 728 | |||
| 729 | gi = unix_gid_find(cred->cr_uid, rqstp); | ||
| 730 | switch (PTR_ERR(gi)) { | ||
| 731 | case -EAGAIN: | ||
| 732 | return SVC_DROP; | ||
| 733 | case -ENOENT: | ||
| 734 | break; | ||
| 735 | default: | ||
| 736 | put_group_info(cred->cr_group_info); | ||
| 737 | cred->cr_group_info = gi; | ||
| 738 | } | ||
| 724 | return SVC_OK; | 739 | return SVC_OK; |
| 725 | } | 740 | } |
| 726 | 741 | ||
| @@ -817,19 +832,11 @@ svcauth_unix_accept(struct svc_rqst *rqstp, __be32 *authp) | |||
| 817 | slen = svc_getnl(argv); /* gids length */ | 832 | slen = svc_getnl(argv); /* gids length */ |
| 818 | if (slen > 16 || (len -= (slen + 2)*4) < 0) | 833 | if (slen > 16 || (len -= (slen + 2)*4) < 0) |
| 819 | goto badcred; | 834 | goto badcred; |
| 820 | if (unix_gid_find(cred->cr_uid, &cred->cr_group_info, rqstp) | 835 | cred->cr_group_info = groups_alloc(slen); |
| 821 | == -EAGAIN) | 836 | if (cred->cr_group_info == NULL) |
| 822 | return SVC_DROP; | 837 | return SVC_DROP; |
| 823 | if (cred->cr_group_info == NULL) { | 838 | for (i = 0; i < slen; i++) |
| 824 | cred->cr_group_info = groups_alloc(slen); | 839 | GROUP_AT(cred->cr_group_info, i) = svc_getnl(argv); |
| 825 | if (cred->cr_group_info == NULL) | ||
| 826 | return SVC_DROP; | ||
| 827 | for (i = 0; i < slen; i++) | ||
| 828 | GROUP_AT(cred->cr_group_info, i) = svc_getnl(argv); | ||
| 829 | } else { | ||
| 830 | for (i = 0; i < slen ; i++) | ||
| 831 | svc_getnl(argv); | ||
| 832 | } | ||
| 833 | if (svc_getu32(argv) != htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) { | 840 | if (svc_getu32(argv) != htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) { |
| 834 | *authp = rpc_autherr_badverf; | 841 | *authp = rpc_autherr_badverf; |
| 835 | return SVC_DENIED; | 842 | return SVC_DENIED; |
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index fd46d42afa89..469de292c23c 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
| @@ -700,6 +700,10 @@ void xprt_connect(struct rpc_task *task) | |||
| 700 | } | 700 | } |
| 701 | if (!xprt_lock_write(xprt, task)) | 701 | if (!xprt_lock_write(xprt, task)) |
| 702 | return; | 702 | return; |
| 703 | |||
| 704 | if (test_and_clear_bit(XPRT_CLOSE_WAIT, &xprt->state)) | ||
| 705 | xprt->ops->close(xprt); | ||
| 706 | |||
| 703 | if (xprt_connected(xprt)) | 707 | if (xprt_connected(xprt)) |
| 704 | xprt_release_write(xprt, task); | 708 | xprt_release_write(xprt, task); |
| 705 | else { | 709 | else { |
diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c index f11be72a1a80..b15e1ebb2bfa 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c | |||
| @@ -54,7 +54,7 @@ | |||
| 54 | * Assumptions: | 54 | * Assumptions: |
| 55 | * - head[0] is physically contiguous. | 55 | * - head[0] is physically contiguous. |
| 56 | * - tail[0] is physically contiguous. | 56 | * - tail[0] is physically contiguous. |
| 57 | * - pages[] is not physically or virtually contigous and consists of | 57 | * - pages[] is not physically or virtually contiguous and consists of |
| 58 | * PAGE_SIZE elements. | 58 | * PAGE_SIZE elements. |
| 59 | * | 59 | * |
| 60 | * Output: | 60 | * Output: |
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 04732d09013e..3d739e5d15d8 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
| @@ -2019,7 +2019,7 @@ static void xs_connect(struct rpc_task *task) | |||
| 2019 | if (xprt_test_and_set_connecting(xprt)) | 2019 | if (xprt_test_and_set_connecting(xprt)) |
| 2020 | return; | 2020 | return; |
| 2021 | 2021 | ||
| 2022 | if (transport->sock != NULL) { | 2022 | if (transport->sock != NULL && !RPC_IS_SOFTCONN(task)) { |
| 2023 | dprintk("RPC: xs_connect delayed xprt %p for %lu " | 2023 | dprintk("RPC: xs_connect delayed xprt %p for %lu " |
| 2024 | "seconds\n", | 2024 | "seconds\n", |
| 2025 | xprt, xprt->reestablish_timeout / HZ); | 2025 | xprt, xprt->reestablish_timeout / HZ); |
diff --git a/net/wimax/op-reset.c b/net/wimax/op-reset.c index ca269178c4d4..35f370091f4f 100644 --- a/net/wimax/op-reset.c +++ b/net/wimax/op-reset.c | |||
| @@ -62,7 +62,7 @@ | |||
| 62 | * Called when wanting to reset the device for any reason. Device is | 62 | * Called when wanting to reset the device for any reason. Device is |
| 63 | * taken back to power on status. | 63 | * taken back to power on status. |
| 64 | * | 64 | * |
| 65 | * This call blocks; on succesful return, the device has completed the | 65 | * This call blocks; on successful return, the device has completed the |
| 66 | * reset process and is ready to operate. | 66 | * reset process and is ready to operate. |
| 67 | */ | 67 | */ |
| 68 | int wimax_reset(struct wimax_dev *wimax_dev) | 68 | int wimax_reset(struct wimax_dev *wimax_dev) |
diff --git a/net/wireless/core.c b/net/wireless/core.c index c2a2c563d21a..92b812442488 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c | |||
| @@ -745,9 +745,9 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb, | |||
| 745 | mutex_unlock(&rdev->devlist_mtx); | 745 | mutex_unlock(&rdev->devlist_mtx); |
| 746 | dev_put(dev); | 746 | dev_put(dev); |
| 747 | } | 747 | } |
| 748 | #ifdef CONFIG_CFG80211_WEXT | ||
| 749 | cfg80211_lock_rdev(rdev); | 748 | cfg80211_lock_rdev(rdev); |
| 750 | mutex_lock(&rdev->devlist_mtx); | 749 | mutex_lock(&rdev->devlist_mtx); |
| 750 | #ifdef CONFIG_CFG80211_WEXT | ||
| 751 | wdev_lock(wdev); | 751 | wdev_lock(wdev); |
| 752 | switch (wdev->iftype) { | 752 | switch (wdev->iftype) { |
| 753 | case NL80211_IFTYPE_ADHOC: | 753 | case NL80211_IFTYPE_ADHOC: |
| @@ -760,10 +760,10 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb, | |||
| 760 | break; | 760 | break; |
| 761 | } | 761 | } |
| 762 | wdev_unlock(wdev); | 762 | wdev_unlock(wdev); |
| 763 | #endif | ||
| 763 | rdev->opencount++; | 764 | rdev->opencount++; |
| 764 | mutex_unlock(&rdev->devlist_mtx); | 765 | mutex_unlock(&rdev->devlist_mtx); |
| 765 | cfg80211_unlock_rdev(rdev); | 766 | cfg80211_unlock_rdev(rdev); |
| 766 | #endif | ||
| 767 | break; | 767 | break; |
| 768 | case NETDEV_UNREGISTER: | 768 | case NETDEV_UNREGISTER: |
| 769 | /* | 769 | /* |
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index 1001db4912f7..82e6002c8d67 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c | |||
| @@ -93,7 +93,18 @@ void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len) | |||
| 93 | } | 93 | } |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | WARN_ON(!bss); | 96 | /* |
| 97 | * We might be coming here because the driver reported | ||
| 98 | * a successful association at the same time as the | ||
| 99 | * user requested a deauth. In that case, we will have | ||
| 100 | * removed the BSS from the auth_bsses list due to the | ||
| 101 | * deauth request when the assoc response makes it. If | ||
| 102 | * the two code paths acquire the lock the other way | ||
| 103 | * around, that's just the standard situation of a | ||
| 104 | * deauth being requested while connected. | ||
| 105 | */ | ||
| 106 | if (!bss) | ||
| 107 | goto out; | ||
| 97 | } else if (wdev->conn) { | 108 | } else if (wdev->conn) { |
| 98 | cfg80211_sme_failed_assoc(wdev); | 109 | cfg80211_sme_failed_assoc(wdev); |
| 99 | /* | 110 | /* |
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index c01470e7de15..7a0754c92df4 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
| @@ -141,62 +141,35 @@ static const struct ieee80211_regdomain us_regdom = { | |||
| 141 | .reg_rules = { | 141 | .reg_rules = { |
| 142 | /* IEEE 802.11b/g, channels 1..11 */ | 142 | /* IEEE 802.11b/g, channels 1..11 */ |
| 143 | REG_RULE(2412-10, 2462+10, 40, 6, 27, 0), | 143 | REG_RULE(2412-10, 2462+10, 40, 6, 27, 0), |
| 144 | /* IEEE 802.11a, channel 36 */ | 144 | /* IEEE 802.11a, channel 36..48 */ |
| 145 | REG_RULE(5180-10, 5180+10, 40, 6, 23, 0), | 145 | REG_RULE(5180-10, 5240+10, 40, 6, 17, 0), |
| 146 | /* IEEE 802.11a, channel 40 */ | ||
| 147 | REG_RULE(5200-10, 5200+10, 40, 6, 23, 0), | ||
| 148 | /* IEEE 802.11a, channel 44 */ | ||
| 149 | REG_RULE(5220-10, 5220+10, 40, 6, 23, 0), | ||
| 150 | /* IEEE 802.11a, channels 48..64 */ | 146 | /* IEEE 802.11a, channels 48..64 */ |
| 151 | REG_RULE(5240-10, 5320+10, 40, 6, 23, 0), | 147 | REG_RULE(5260-10, 5320+10, 40, 6, 20, NL80211_RRF_DFS), |
| 148 | /* IEEE 802.11a, channels 100..124 */ | ||
| 149 | REG_RULE(5500-10, 5590+10, 40, 6, 20, NL80211_RRF_DFS), | ||
| 150 | /* IEEE 802.11a, channels 132..144 */ | ||
| 151 | REG_RULE(5660-10, 5700+10, 40, 6, 20, NL80211_RRF_DFS), | ||
| 152 | /* IEEE 802.11a, channels 149..165, outdoor */ | 152 | /* IEEE 802.11a, channels 149..165, outdoor */ |
| 153 | REG_RULE(5745-10, 5825+10, 40, 6, 30, 0), | 153 | REG_RULE(5745-10, 5825+10, 40, 6, 30, 0), |
| 154 | } | 154 | } |
| 155 | }; | 155 | }; |
| 156 | 156 | ||
| 157 | static const struct ieee80211_regdomain jp_regdom = { | 157 | static const struct ieee80211_regdomain jp_regdom = { |
| 158 | .n_reg_rules = 3, | 158 | .n_reg_rules = 6, |
| 159 | .alpha2 = "JP", | 159 | .alpha2 = "JP", |
| 160 | .reg_rules = { | 160 | .reg_rules = { |
| 161 | /* IEEE 802.11b/g, channels 1..14 */ | 161 | /* IEEE 802.11b/g, channels 1..11 */ |
| 162 | REG_RULE(2412-10, 2484+10, 40, 6, 20, 0), | 162 | REG_RULE(2412-10, 2462+10, 40, 6, 20, 0), |
| 163 | /* IEEE 802.11a, channels 34..48 */ | 163 | /* IEEE 802.11b/g, channels 12..13 */ |
| 164 | REG_RULE(5170-10, 5240+10, 40, 6, 20, | 164 | REG_RULE(2467-10, 2472+10, 20, 6, 20, 0), |
| 165 | NL80211_RRF_PASSIVE_SCAN), | 165 | /* IEEE 802.11b/g, channel 14 */ |
| 166 | REG_RULE(2484-10, 2484+10, 20, 6, 20, NL80211_RRF_NO_OFDM), | ||
| 167 | /* IEEE 802.11a, channels 36..48 */ | ||
| 168 | REG_RULE(5180-10, 5240+10, 40, 6, 20, 0), | ||
| 166 | /* IEEE 802.11a, channels 52..64 */ | 169 | /* IEEE 802.11a, channels 52..64 */ |
| 167 | REG_RULE(5260-10, 5320+10, 40, 6, 20, | 170 | REG_RULE(5260-10, 5320+10, 40, 6, 20, NL80211_RRF_DFS), |
| 168 | NL80211_RRF_NO_IBSS | | 171 | /* IEEE 802.11a, channels 100..144 */ |
| 169 | NL80211_RRF_DFS), | 172 | REG_RULE(5500-10, 5700+10, 40, 6, 23, NL80211_RRF_DFS), |
| 170 | } | ||
| 171 | }; | ||
| 172 | |||
| 173 | static const struct ieee80211_regdomain eu_regdom = { | ||
| 174 | .n_reg_rules = 6, | ||
| 175 | /* | ||
| 176 | * This alpha2 is bogus, we leave it here just for stupid | ||
| 177 | * backward compatibility | ||
| 178 | */ | ||
| 179 | .alpha2 = "EU", | ||
| 180 | .reg_rules = { | ||
| 181 | /* IEEE 802.11b/g, channels 1..13 */ | ||
| 182 | REG_RULE(2412-10, 2472+10, 40, 6, 20, 0), | ||
| 183 | /* IEEE 802.11a, channel 36 */ | ||
| 184 | REG_RULE(5180-10, 5180+10, 40, 6, 23, | ||
| 185 | NL80211_RRF_PASSIVE_SCAN), | ||
| 186 | /* IEEE 802.11a, channel 40 */ | ||
| 187 | REG_RULE(5200-10, 5200+10, 40, 6, 23, | ||
| 188 | NL80211_RRF_PASSIVE_SCAN), | ||
| 189 | /* IEEE 802.11a, channel 44 */ | ||
| 190 | REG_RULE(5220-10, 5220+10, 40, 6, 23, | ||
| 191 | NL80211_RRF_PASSIVE_SCAN), | ||
| 192 | /* IEEE 802.11a, channels 48..64 */ | ||
| 193 | REG_RULE(5240-10, 5320+10, 40, 6, 20, | ||
| 194 | NL80211_RRF_NO_IBSS | | ||
| 195 | NL80211_RRF_DFS), | ||
| 196 | /* IEEE 802.11a, channels 100..140 */ | ||
| 197 | REG_RULE(5500-10, 5700+10, 40, 6, 30, | ||
| 198 | NL80211_RRF_NO_IBSS | | ||
| 199 | NL80211_RRF_DFS), | ||
| 200 | } | 173 | } |
| 201 | }; | 174 | }; |
| 202 | 175 | ||
| @@ -206,15 +179,17 @@ static const struct ieee80211_regdomain *static_regdom(char *alpha2) | |||
| 206 | return &us_regdom; | 179 | return &us_regdom; |
| 207 | if (alpha2[0] == 'J' && alpha2[1] == 'P') | 180 | if (alpha2[0] == 'J' && alpha2[1] == 'P') |
| 208 | return &jp_regdom; | 181 | return &jp_regdom; |
| 182 | /* Use world roaming rules for "EU", since it was a pseudo | ||
| 183 | domain anyway... */ | ||
| 209 | if (alpha2[0] == 'E' && alpha2[1] == 'U') | 184 | if (alpha2[0] == 'E' && alpha2[1] == 'U') |
| 210 | return &eu_regdom; | 185 | return &world_regdom; |
| 211 | /* Default, as per the old rules */ | 186 | /* Default, world roaming rules */ |
| 212 | return &us_regdom; | 187 | return &world_regdom; |
| 213 | } | 188 | } |
| 214 | 189 | ||
| 215 | static bool is_old_static_regdom(const struct ieee80211_regdomain *rd) | 190 | static bool is_old_static_regdom(const struct ieee80211_regdomain *rd) |
| 216 | { | 191 | { |
| 217 | if (rd == &us_regdom || rd == &jp_regdom || rd == &eu_regdom) | 192 | if (rd == &us_regdom || rd == &jp_regdom || rd == &world_regdom) |
| 218 | return true; | 193 | return true; |
| 219 | return false; | 194 | return false; |
| 220 | } | 195 | } |
| @@ -1715,7 +1690,7 @@ int regulatory_hint_user(const char *alpha2) | |||
| 1715 | request->wiphy_idx = WIPHY_IDX_STALE; | 1690 | request->wiphy_idx = WIPHY_IDX_STALE; |
| 1716 | request->alpha2[0] = alpha2[0]; | 1691 | request->alpha2[0] = alpha2[0]; |
| 1717 | request->alpha2[1] = alpha2[1]; | 1692 | request->alpha2[1] = alpha2[1]; |
| 1718 | request->initiator = NL80211_REGDOM_SET_BY_USER, | 1693 | request->initiator = NL80211_REGDOM_SET_BY_USER; |
| 1719 | 1694 | ||
| 1720 | queue_regulatory_request(request); | 1695 | queue_regulatory_request(request); |
| 1721 | 1696 | ||
diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 12dfa62aad18..0c2cbbebca95 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c | |||
| @@ -601,7 +601,7 @@ int cfg80211_wext_siwscan(struct net_device *dev, | |||
| 601 | struct cfg80211_registered_device *rdev; | 601 | struct cfg80211_registered_device *rdev; |
| 602 | struct wiphy *wiphy; | 602 | struct wiphy *wiphy; |
| 603 | struct iw_scan_req *wreq = NULL; | 603 | struct iw_scan_req *wreq = NULL; |
| 604 | struct cfg80211_scan_request *creq; | 604 | struct cfg80211_scan_request *creq = NULL; |
| 605 | int i, err, n_channels = 0; | 605 | int i, err, n_channels = 0; |
| 606 | enum ieee80211_band band; | 606 | enum ieee80211_band band; |
| 607 | 607 | ||
| @@ -694,8 +694,10 @@ int cfg80211_wext_siwscan(struct net_device *dev, | |||
| 694 | /* translate "Scan for SSID" request */ | 694 | /* translate "Scan for SSID" request */ |
| 695 | if (wreq) { | 695 | if (wreq) { |
| 696 | if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { | 696 | if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { |
| 697 | if (wreq->essid_len > IEEE80211_MAX_SSID_LEN) | 697 | if (wreq->essid_len > IEEE80211_MAX_SSID_LEN) { |
| 698 | return -EINVAL; | 698 | err = -EINVAL; |
| 699 | goto out; | ||
| 700 | } | ||
| 699 | memcpy(creq->ssids[0].ssid, wreq->essid, wreq->essid_len); | 701 | memcpy(creq->ssids[0].ssid, wreq->essid, wreq->essid_len); |
| 700 | creq->ssids[0].ssid_len = wreq->essid_len; | 702 | creq->ssids[0].ssid_len = wreq->essid_len; |
| 701 | } | 703 | } |
| @@ -707,12 +709,15 @@ int cfg80211_wext_siwscan(struct net_device *dev, | |||
| 707 | err = rdev->ops->scan(wiphy, dev, creq); | 709 | err = rdev->ops->scan(wiphy, dev, creq); |
| 708 | if (err) { | 710 | if (err) { |
| 709 | rdev->scan_req = NULL; | 711 | rdev->scan_req = NULL; |
| 710 | kfree(creq); | 712 | /* creq will be freed below */ |
| 711 | } else { | 713 | } else { |
| 712 | nl80211_send_scan_start(rdev, dev); | 714 | nl80211_send_scan_start(rdev, dev); |
| 715 | /* creq now owned by driver */ | ||
| 716 | creq = NULL; | ||
| 713 | dev_hold(dev); | 717 | dev_hold(dev); |
| 714 | } | 718 | } |
| 715 | out: | 719 | out: |
| 720 | kfree(creq); | ||
| 716 | cfg80211_unlock_rdev(rdev); | 721 | cfg80211_unlock_rdev(rdev); |
| 717 | return err; | 722 | return err; |
| 718 | } | 723 | } |
diff --git a/net/wireless/sme.c b/net/wireless/sme.c index 2333d78187e4..dc0fc4989d54 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c | |||
| @@ -655,6 +655,7 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie, | |||
| 655 | memset(&wrqu, 0, sizeof(wrqu)); | 655 | memset(&wrqu, 0, sizeof(wrqu)); |
| 656 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; | 656 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 657 | wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL); | 657 | wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL); |
| 658 | wdev->wext.connect.ssid_len = 0; | ||
| 658 | #endif | 659 | #endif |
| 659 | } | 660 | } |
| 660 | 661 | ||
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c index 584eb4826e02..54face3d4424 100644 --- a/net/wireless/wext-compat.c +++ b/net/wireless/wext-compat.c | |||
| @@ -479,6 +479,7 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev, | |||
| 479 | } | 479 | } |
| 480 | err = rdev->ops->del_key(&rdev->wiphy, dev, idx, addr); | 480 | err = rdev->ops->del_key(&rdev->wiphy, dev, idx, addr); |
| 481 | } | 481 | } |
| 482 | wdev->wext.connect.privacy = false; | ||
| 482 | /* | 483 | /* |
| 483 | * Applications using wireless extensions expect to be | 484 | * Applications using wireless extensions expect to be |
| 484 | * able to delete keys that don't exist, so allow that. | 485 | * able to delete keys that don't exist, so allow that. |
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c index 743c0134a6a9..8b4d6e3246e5 100644 --- a/net/xfrm/xfrm_algo.c +++ b/net/xfrm/xfrm_algo.c | |||
| @@ -125,6 +125,22 @@ static struct xfrm_algo_desc aead_list[] = { | |||
| 125 | .sadb_alg_maxbits = 256 | 125 | .sadb_alg_maxbits = 256 |
| 126 | } | 126 | } |
| 127 | }, | 127 | }, |
| 128 | { | ||
| 129 | .name = "rfc4543(gcm(aes))", | ||
| 130 | |||
| 131 | .uinfo = { | ||
| 132 | .aead = { | ||
| 133 | .icv_truncbits = 128, | ||
| 134 | } | ||
| 135 | }, | ||
| 136 | |||
| 137 | .desc = { | ||
| 138 | .sadb_alg_id = SADB_X_EALG_NULL_AES_GMAC, | ||
| 139 | .sadb_alg_ivlen = 8, | ||
| 140 | .sadb_alg_minbits = 128, | ||
| 141 | .sadb_alg_maxbits = 256 | ||
| 142 | } | ||
| 143 | }, | ||
| 128 | }; | 144 | }; |
| 129 | 145 | ||
| 130 | static struct xfrm_algo_desc aalg_list[] = { | 146 | static struct xfrm_algo_desc aalg_list[] = { |
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index cb81ca35b0d6..0ecb16a9a883 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
| @@ -469,16 +469,16 @@ static inline int xfrm_byidx_should_resize(struct net *net, int total) | |||
| 469 | return 0; | 469 | return 0; |
| 470 | } | 470 | } |
| 471 | 471 | ||
| 472 | void xfrm_spd_getinfo(struct xfrmk_spdinfo *si) | 472 | void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si) |
| 473 | { | 473 | { |
| 474 | read_lock_bh(&xfrm_policy_lock); | 474 | read_lock_bh(&xfrm_policy_lock); |
| 475 | si->incnt = init_net.xfrm.policy_count[XFRM_POLICY_IN]; | 475 | si->incnt = net->xfrm.policy_count[XFRM_POLICY_IN]; |
| 476 | si->outcnt = init_net.xfrm.policy_count[XFRM_POLICY_OUT]; | 476 | si->outcnt = net->xfrm.policy_count[XFRM_POLICY_OUT]; |
| 477 | si->fwdcnt = init_net.xfrm.policy_count[XFRM_POLICY_FWD]; | 477 | si->fwdcnt = net->xfrm.policy_count[XFRM_POLICY_FWD]; |
| 478 | si->inscnt = init_net.xfrm.policy_count[XFRM_POLICY_IN+XFRM_POLICY_MAX]; | 478 | si->inscnt = net->xfrm.policy_count[XFRM_POLICY_IN+XFRM_POLICY_MAX]; |
| 479 | si->outscnt = init_net.xfrm.policy_count[XFRM_POLICY_OUT+XFRM_POLICY_MAX]; | 479 | si->outscnt = net->xfrm.policy_count[XFRM_POLICY_OUT+XFRM_POLICY_MAX]; |
| 480 | si->fwdscnt = init_net.xfrm.policy_count[XFRM_POLICY_FWD+XFRM_POLICY_MAX]; | 480 | si->fwdscnt = net->xfrm.policy_count[XFRM_POLICY_FWD+XFRM_POLICY_MAX]; |
| 481 | si->spdhcnt = init_net.xfrm.policy_idx_hmask; | 481 | si->spdhcnt = net->xfrm.policy_idx_hmask; |
| 482 | si->spdhmcnt = xfrm_policy_hashmax; | 482 | si->spdhmcnt = xfrm_policy_hashmax; |
| 483 | read_unlock_bh(&xfrm_policy_lock); | 483 | read_unlock_bh(&xfrm_policy_lock); |
| 484 | } | 484 | } |
| @@ -1309,15 +1309,28 @@ static inline int xfrm_get_tos(struct flowi *fl, int family) | |||
| 1309 | return tos; | 1309 | return tos; |
| 1310 | } | 1310 | } |
| 1311 | 1311 | ||
| 1312 | static inline struct xfrm_dst *xfrm_alloc_dst(int family) | 1312 | static inline struct xfrm_dst *xfrm_alloc_dst(struct net *net, int family) |
| 1313 | { | 1313 | { |
| 1314 | struct xfrm_policy_afinfo *afinfo = xfrm_policy_get_afinfo(family); | 1314 | struct xfrm_policy_afinfo *afinfo = xfrm_policy_get_afinfo(family); |
| 1315 | struct dst_ops *dst_ops; | ||
| 1315 | struct xfrm_dst *xdst; | 1316 | struct xfrm_dst *xdst; |
| 1316 | 1317 | ||
| 1317 | if (!afinfo) | 1318 | if (!afinfo) |
| 1318 | return ERR_PTR(-EINVAL); | 1319 | return ERR_PTR(-EINVAL); |
| 1319 | 1320 | ||
| 1320 | xdst = dst_alloc(afinfo->dst_ops) ?: ERR_PTR(-ENOBUFS); | 1321 | switch (family) { |
| 1322 | case AF_INET: | ||
| 1323 | dst_ops = &net->xfrm.xfrm4_dst_ops; | ||
| 1324 | break; | ||
| 1325 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
| 1326 | case AF_INET6: | ||
| 1327 | dst_ops = &net->xfrm.xfrm6_dst_ops; | ||
| 1328 | break; | ||
| 1329 | #endif | ||
| 1330 | default: | ||
| 1331 | BUG(); | ||
| 1332 | } | ||
| 1333 | xdst = dst_alloc(dst_ops) ?: ERR_PTR(-ENOBUFS); | ||
| 1321 | 1334 | ||
| 1322 | xfrm_policy_put_afinfo(afinfo); | 1335 | xfrm_policy_put_afinfo(afinfo); |
| 1323 | 1336 | ||
| @@ -1366,6 +1379,7 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, | |||
| 1366 | struct flowi *fl, | 1379 | struct flowi *fl, |
| 1367 | struct dst_entry *dst) | 1380 | struct dst_entry *dst) |
| 1368 | { | 1381 | { |
| 1382 | struct net *net = xp_net(policy); | ||
| 1369 | unsigned long now = jiffies; | 1383 | unsigned long now = jiffies; |
| 1370 | struct net_device *dev; | 1384 | struct net_device *dev; |
| 1371 | struct dst_entry *dst_prev = NULL; | 1385 | struct dst_entry *dst_prev = NULL; |
| @@ -1389,7 +1403,7 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, | |||
| 1389 | dst_hold(dst); | 1403 | dst_hold(dst); |
| 1390 | 1404 | ||
| 1391 | for (; i < nx; i++) { | 1405 | for (; i < nx; i++) { |
| 1392 | struct xfrm_dst *xdst = xfrm_alloc_dst(family); | 1406 | struct xfrm_dst *xdst = xfrm_alloc_dst(net, family); |
| 1393 | struct dst_entry *dst1 = &xdst->u.dst; | 1407 | struct dst_entry *dst1 = &xdst->u.dst; |
| 1394 | 1408 | ||
| 1395 | err = PTR_ERR(xdst); | 1409 | err = PTR_ERR(xdst); |
| @@ -1445,7 +1459,7 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, | |||
| 1445 | if (!dev) | 1459 | if (!dev) |
| 1446 | goto free_dst; | 1460 | goto free_dst; |
| 1447 | 1461 | ||
| 1448 | /* Copy neighbout for reachability confirmation */ | 1462 | /* Copy neighbour for reachability confirmation */ |
| 1449 | dst0->neighbour = neigh_clone(dst->neighbour); | 1463 | dst0->neighbour = neigh_clone(dst->neighbour); |
| 1450 | 1464 | ||
| 1451 | xfrm_init_path((struct xfrm_dst *)dst0, dst, nfheader_len); | 1465 | xfrm_init_path((struct xfrm_dst *)dst0, dst, nfheader_len); |
| @@ -2279,6 +2293,7 @@ EXPORT_SYMBOL(xfrm_bundle_ok); | |||
| 2279 | 2293 | ||
| 2280 | int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo) | 2294 | int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo) |
| 2281 | { | 2295 | { |
| 2296 | struct net *net; | ||
| 2282 | int err = 0; | 2297 | int err = 0; |
| 2283 | if (unlikely(afinfo == NULL)) | 2298 | if (unlikely(afinfo == NULL)) |
| 2284 | return -EINVAL; | 2299 | return -EINVAL; |
| @@ -2302,6 +2317,27 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo) | |||
| 2302 | xfrm_policy_afinfo[afinfo->family] = afinfo; | 2317 | xfrm_policy_afinfo[afinfo->family] = afinfo; |
| 2303 | } | 2318 | } |
| 2304 | write_unlock_bh(&xfrm_policy_afinfo_lock); | 2319 | write_unlock_bh(&xfrm_policy_afinfo_lock); |
| 2320 | |||
| 2321 | rtnl_lock(); | ||
| 2322 | for_each_net(net) { | ||
| 2323 | struct dst_ops *xfrm_dst_ops; | ||
| 2324 | |||
| 2325 | switch (afinfo->family) { | ||
| 2326 | case AF_INET: | ||
| 2327 | xfrm_dst_ops = &net->xfrm.xfrm4_dst_ops; | ||
| 2328 | break; | ||
| 2329 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
| 2330 | case AF_INET6: | ||
| 2331 | xfrm_dst_ops = &net->xfrm.xfrm6_dst_ops; | ||
| 2332 | break; | ||
| 2333 | #endif | ||
| 2334 | default: | ||
| 2335 | BUG(); | ||
| 2336 | } | ||
| 2337 | *xfrm_dst_ops = *afinfo->dst_ops; | ||
| 2338 | } | ||
| 2339 | rtnl_unlock(); | ||
| 2340 | |||
| 2305 | return err; | 2341 | return err; |
| 2306 | } | 2342 | } |
| 2307 | EXPORT_SYMBOL(xfrm_policy_register_afinfo); | 2343 | EXPORT_SYMBOL(xfrm_policy_register_afinfo); |
| @@ -2332,6 +2368,22 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo) | |||
| 2332 | } | 2368 | } |
| 2333 | EXPORT_SYMBOL(xfrm_policy_unregister_afinfo); | 2369 | EXPORT_SYMBOL(xfrm_policy_unregister_afinfo); |
| 2334 | 2370 | ||
| 2371 | static void __net_init xfrm_dst_ops_init(struct net *net) | ||
| 2372 | { | ||
| 2373 | struct xfrm_policy_afinfo *afinfo; | ||
| 2374 | |||
| 2375 | read_lock_bh(&xfrm_policy_afinfo_lock); | ||
| 2376 | afinfo = xfrm_policy_afinfo[AF_INET]; | ||
| 2377 | if (afinfo) | ||
| 2378 | net->xfrm.xfrm4_dst_ops = *afinfo->dst_ops; | ||
| 2379 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
| 2380 | afinfo = xfrm_policy_afinfo[AF_INET6]; | ||
| 2381 | if (afinfo) | ||
| 2382 | net->xfrm.xfrm6_dst_ops = *afinfo->dst_ops; | ||
| 2383 | #endif | ||
| 2384 | read_unlock_bh(&xfrm_policy_afinfo_lock); | ||
| 2385 | } | ||
| 2386 | |||
| 2335 | static struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family) | 2387 | static struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family) |
| 2336 | { | 2388 | { |
| 2337 | struct xfrm_policy_afinfo *afinfo; | 2389 | struct xfrm_policy_afinfo *afinfo; |
| @@ -2494,6 +2546,7 @@ static int __net_init xfrm_net_init(struct net *net) | |||
| 2494 | rv = xfrm_policy_init(net); | 2546 | rv = xfrm_policy_init(net); |
| 2495 | if (rv < 0) | 2547 | if (rv < 0) |
| 2496 | goto out_policy; | 2548 | goto out_policy; |
| 2549 | xfrm_dst_ops_init(net); | ||
| 2497 | rv = xfrm_sysctl_init(net); | 2550 | rv = xfrm_sysctl_init(net); |
| 2498 | if (rv < 0) | 2551 | if (rv < 0) |
| 2499 | goto out_sysctl; | 2552 | goto out_sysctl; |
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index d847f1a52b44..f445ea1c5f52 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
| @@ -641,11 +641,11 @@ out: | |||
| 641 | } | 641 | } |
| 642 | EXPORT_SYMBOL(xfrm_state_flush); | 642 | EXPORT_SYMBOL(xfrm_state_flush); |
| 643 | 643 | ||
| 644 | void xfrm_sad_getinfo(struct xfrmk_sadinfo *si) | 644 | void xfrm_sad_getinfo(struct net *net, struct xfrmk_sadinfo *si) |
| 645 | { | 645 | { |
| 646 | spin_lock_bh(&xfrm_state_lock); | 646 | spin_lock_bh(&xfrm_state_lock); |
| 647 | si->sadcnt = init_net.xfrm.state_num; | 647 | si->sadcnt = net->xfrm.state_num; |
| 648 | si->sadhcnt = init_net.xfrm.state_hmask; | 648 | si->sadhcnt = net->xfrm.state_hmask; |
| 649 | si->sadhmcnt = xfrm_state_hashmax; | 649 | si->sadhmcnt = xfrm_state_hashmax; |
| 650 | spin_unlock_bh(&xfrm_state_lock); | 650 | spin_unlock_bh(&xfrm_state_lock); |
| 651 | } | 651 | } |
| @@ -1102,7 +1102,7 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp) | |||
| 1102 | int err = -ENOMEM; | 1102 | int err = -ENOMEM; |
| 1103 | struct xfrm_state *x = xfrm_state_alloc(net); | 1103 | struct xfrm_state *x = xfrm_state_alloc(net); |
| 1104 | if (!x) | 1104 | if (!x) |
| 1105 | goto error; | 1105 | goto out; |
| 1106 | 1106 | ||
| 1107 | memcpy(&x->id, &orig->id, sizeof(x->id)); | 1107 | memcpy(&x->id, &orig->id, sizeof(x->id)); |
| 1108 | memcpy(&x->sel, &orig->sel, sizeof(x->sel)); | 1108 | memcpy(&x->sel, &orig->sel, sizeof(x->sel)); |
| @@ -1160,16 +1160,10 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp) | |||
| 1160 | return x; | 1160 | return x; |
| 1161 | 1161 | ||
| 1162 | error: | 1162 | error: |
| 1163 | xfrm_state_put(x); | ||
| 1164 | out: | ||
| 1163 | if (errp) | 1165 | if (errp) |
| 1164 | *errp = err; | 1166 | *errp = err; |
| 1165 | if (x) { | ||
| 1166 | kfree(x->aalg); | ||
| 1167 | kfree(x->ealg); | ||
| 1168 | kfree(x->calg); | ||
| 1169 | kfree(x->encap); | ||
| 1170 | kfree(x->coaddr); | ||
| 1171 | } | ||
| 1172 | kfree(x); | ||
| 1173 | return NULL; | 1167 | return NULL; |
| 1174 | } | 1168 | } |
| 1175 | 1169 | ||
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 1ada6186933c..d5a712976004 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
| @@ -781,7 +781,8 @@ static inline size_t xfrm_spdinfo_msgsize(void) | |||
| 781 | + nla_total_size(sizeof(struct xfrmu_spdhinfo)); | 781 | + nla_total_size(sizeof(struct xfrmu_spdhinfo)); |
| 782 | } | 782 | } |
| 783 | 783 | ||
| 784 | static int build_spdinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags) | 784 | static int build_spdinfo(struct sk_buff *skb, struct net *net, |
| 785 | u32 pid, u32 seq, u32 flags) | ||
| 785 | { | 786 | { |
| 786 | struct xfrmk_spdinfo si; | 787 | struct xfrmk_spdinfo si; |
| 787 | struct xfrmu_spdinfo spc; | 788 | struct xfrmu_spdinfo spc; |
| @@ -795,7 +796,7 @@ static int build_spdinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags) | |||
| 795 | 796 | ||
| 796 | f = nlmsg_data(nlh); | 797 | f = nlmsg_data(nlh); |
| 797 | *f = flags; | 798 | *f = flags; |
| 798 | xfrm_spd_getinfo(&si); | 799 | xfrm_spd_getinfo(net, &si); |
| 799 | spc.incnt = si.incnt; | 800 | spc.incnt = si.incnt; |
| 800 | spc.outcnt = si.outcnt; | 801 | spc.outcnt = si.outcnt; |
| 801 | spc.fwdcnt = si.fwdcnt; | 802 | spc.fwdcnt = si.fwdcnt; |
| @@ -828,7 +829,7 @@ static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
| 828 | if (r_skb == NULL) | 829 | if (r_skb == NULL) |
| 829 | return -ENOMEM; | 830 | return -ENOMEM; |
| 830 | 831 | ||
| 831 | if (build_spdinfo(r_skb, spid, seq, *flags) < 0) | 832 | if (build_spdinfo(r_skb, net, spid, seq, *flags) < 0) |
| 832 | BUG(); | 833 | BUG(); |
| 833 | 834 | ||
| 834 | return nlmsg_unicast(net->xfrm.nlsk, r_skb, spid); | 835 | return nlmsg_unicast(net->xfrm.nlsk, r_skb, spid); |
| @@ -841,7 +842,8 @@ static inline size_t xfrm_sadinfo_msgsize(void) | |||
| 841 | + nla_total_size(4); /* XFRMA_SAD_CNT */ | 842 | + nla_total_size(4); /* XFRMA_SAD_CNT */ |
| 842 | } | 843 | } |
| 843 | 844 | ||
| 844 | static int build_sadinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags) | 845 | static int build_sadinfo(struct sk_buff *skb, struct net *net, |
| 846 | u32 pid, u32 seq, u32 flags) | ||
| 845 | { | 847 | { |
| 846 | struct xfrmk_sadinfo si; | 848 | struct xfrmk_sadinfo si; |
| 847 | struct xfrmu_sadhinfo sh; | 849 | struct xfrmu_sadhinfo sh; |
| @@ -854,7 +856,7 @@ static int build_sadinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags) | |||
| 854 | 856 | ||
| 855 | f = nlmsg_data(nlh); | 857 | f = nlmsg_data(nlh); |
| 856 | *f = flags; | 858 | *f = flags; |
| 857 | xfrm_sad_getinfo(&si); | 859 | xfrm_sad_getinfo(net, &si); |
| 858 | 860 | ||
| 859 | sh.sadhmcnt = si.sadhmcnt; | 861 | sh.sadhmcnt = si.sadhmcnt; |
| 860 | sh.sadhcnt = si.sadhcnt; | 862 | sh.sadhcnt = si.sadhcnt; |
| @@ -882,7 +884,7 @@ static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
| 882 | if (r_skb == NULL) | 884 | if (r_skb == NULL) |
| 883 | return -ENOMEM; | 885 | return -ENOMEM; |
| 884 | 886 | ||
| 885 | if (build_sadinfo(r_skb, spid, seq, *flags) < 0) | 887 | if (build_sadinfo(r_skb, net, spid, seq, *flags) < 0) |
| 886 | BUG(); | 888 | BUG(); |
| 887 | 889 | ||
| 888 | return nlmsg_unicast(net->xfrm.nlsk, r_skb, spid); | 890 | return nlmsg_unicast(net->xfrm.nlsk, r_skb, spid); |
