diff options
| author | Eric W. Biederman <ebiederm@xmission.com> | 2012-09-07 16:12:54 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2012-09-10 15:30:41 -0400 |
| commit | 15e473046cb6e5d18a4d0057e61d76315230382b (patch) | |
| tree | 893d2df5d46a6ce156933ac57a1398f0ad22b889 /net/netlink | |
| parent | 9f00d9776bc5beb92e8bfc884a7e96ddc5589e2e (diff) | |
netlink: Rename pid to portid to avoid confusion
It is a frequent mistake to confuse the netlink port identifier with a
process identifier. Try to reduce this confusion by renaming fields
that hold port identifiers portid instead of pid.
I have carefully avoided changing the structures exported to
userspace to avoid changing the userspace API.
I have successfully built an allyesconfig kernel with this change.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink')
| -rw-r--r-- | net/netlink/af_netlink.c | 172 | ||||
| -rw-r--r-- | net/netlink/genetlink.c | 42 |
2 files changed, 107 insertions, 107 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 4d348e97e13..0f2e3ad69c4 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
| @@ -67,8 +67,8 @@ | |||
| 67 | struct netlink_sock { | 67 | struct netlink_sock { |
| 68 | /* struct sock has to be the first member of netlink_sock */ | 68 | /* struct sock has to be the first member of netlink_sock */ |
| 69 | struct sock sk; | 69 | struct sock sk; |
| 70 | u32 pid; | 70 | u32 portid; |
| 71 | u32 dst_pid; | 71 | u32 dst_portid; |
| 72 | u32 dst_group; | 72 | u32 dst_group; |
| 73 | u32 flags; | 73 | u32 flags; |
| 74 | u32 subscriptions; | 74 | u32 subscriptions; |
| @@ -104,7 +104,7 @@ static inline int netlink_is_kernel(struct sock *sk) | |||
| 104 | return nlk_sk(sk)->flags & NETLINK_KERNEL_SOCKET; | 104 | return nlk_sk(sk)->flags & NETLINK_KERNEL_SOCKET; |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | struct nl_pid_hash { | 107 | struct nl_portid_hash { |
| 108 | struct hlist_head *table; | 108 | struct hlist_head *table; |
| 109 | unsigned long rehash_time; | 109 | unsigned long rehash_time; |
| 110 | 110 | ||
| @@ -118,7 +118,7 @@ struct nl_pid_hash { | |||
| 118 | }; | 118 | }; |
| 119 | 119 | ||
| 120 | struct netlink_table { | 120 | struct netlink_table { |
| 121 | struct nl_pid_hash hash; | 121 | struct nl_portid_hash hash; |
| 122 | struct hlist_head mc_list; | 122 | struct hlist_head mc_list; |
| 123 | struct listeners __rcu *listeners; | 123 | struct listeners __rcu *listeners; |
| 124 | unsigned int flags; | 124 | unsigned int flags; |
| @@ -145,9 +145,9 @@ static inline u32 netlink_group_mask(u32 group) | |||
| 145 | return group ? 1 << (group - 1) : 0; | 145 | return group ? 1 << (group - 1) : 0; |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | static inline struct hlist_head *nl_pid_hashfn(struct nl_pid_hash *hash, u32 pid) | 148 | static inline struct hlist_head *nl_portid_hashfn(struct nl_portid_hash *hash, u32 portid) |
| 149 | { | 149 | { |
| 150 | return &hash->table[jhash_1word(pid, hash->rnd) & hash->mask]; | 150 | return &hash->table[jhash_1word(portid, hash->rnd) & hash->mask]; |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | static void netlink_destroy_callback(struct netlink_callback *cb) | 153 | static void netlink_destroy_callback(struct netlink_callback *cb) |
| @@ -239,17 +239,17 @@ netlink_unlock_table(void) | |||
| 239 | wake_up(&nl_table_wait); | 239 | wake_up(&nl_table_wait); |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | static struct sock *netlink_lookup(struct net *net, int protocol, u32 pid) | 242 | static struct sock *netlink_lookup(struct net *net, int protocol, u32 portid) |
| 243 | { | 243 | { |
| 244 | struct nl_pid_hash *hash = &nl_table[protocol].hash; | 244 | struct nl_portid_hash *hash = &nl_table[protocol].hash; |
| 245 | struct hlist_head *head; | 245 | struct hlist_head *head; |
| 246 | struct sock *sk; | 246 | struct sock *sk; |
| 247 | struct hlist_node *node; | 247 | struct hlist_node *node; |
| 248 | 248 | ||
| 249 | read_lock(&nl_table_lock); | 249 | read_lock(&nl_table_lock); |
| 250 | head = nl_pid_hashfn(hash, pid); | 250 | head = nl_portid_hashfn(hash, portid); |
| 251 | sk_for_each(sk, node, head) { | 251 | sk_for_each(sk, node, head) { |
| 252 | if (net_eq(sock_net(sk), net) && (nlk_sk(sk)->pid == pid)) { | 252 | if (net_eq(sock_net(sk), net) && (nlk_sk(sk)->portid == portid)) { |
| 253 | sock_hold(sk); | 253 | sock_hold(sk); |
| 254 | goto found; | 254 | goto found; |
| 255 | } | 255 | } |
| @@ -260,7 +260,7 @@ found: | |||
| 260 | return sk; | 260 | return sk; |
| 261 | } | 261 | } |
| 262 | 262 | ||
| 263 | static struct hlist_head *nl_pid_hash_zalloc(size_t size) | 263 | static struct hlist_head *nl_portid_hash_zalloc(size_t size) |
| 264 | { | 264 | { |
| 265 | if (size <= PAGE_SIZE) | 265 | if (size <= PAGE_SIZE) |
| 266 | return kzalloc(size, GFP_ATOMIC); | 266 | return kzalloc(size, GFP_ATOMIC); |
| @@ -270,7 +270,7 @@ static struct hlist_head *nl_pid_hash_zalloc(size_t size) | |||
| 270 | get_order(size)); | 270 | get_order(size)); |
| 271 | } | 271 | } |
| 272 | 272 | ||
| 273 | static void nl_pid_hash_free(struct hlist_head *table, size_t size) | 273 | static void nl_portid_hash_free(struct hlist_head *table, size_t size) |
| 274 | { | 274 | { |
| 275 | if (size <= PAGE_SIZE) | 275 | if (size <= PAGE_SIZE) |
| 276 | kfree(table); | 276 | kfree(table); |
| @@ -278,7 +278,7 @@ static void nl_pid_hash_free(struct hlist_head *table, size_t size) | |||
| 278 | free_pages((unsigned long)table, get_order(size)); | 278 | free_pages((unsigned long)table, get_order(size)); |
| 279 | } | 279 | } |
| 280 | 280 | ||
| 281 | static int nl_pid_hash_rehash(struct nl_pid_hash *hash, int grow) | 281 | static int nl_portid_hash_rehash(struct nl_portid_hash *hash, int grow) |
| 282 | { | 282 | { |
| 283 | unsigned int omask, mask, shift; | 283 | unsigned int omask, mask, shift; |
| 284 | size_t osize, size; | 284 | size_t osize, size; |
| @@ -296,7 +296,7 @@ static int nl_pid_hash_rehash(struct nl_pid_hash *hash, int grow) | |||
| 296 | size *= 2; | 296 | size *= 2; |
| 297 | } | 297 | } |
| 298 | 298 | ||
| 299 | table = nl_pid_hash_zalloc(size); | 299 | table = nl_portid_hash_zalloc(size); |
| 300 | if (!table) | 300 | if (!table) |
| 301 | return 0; | 301 | return 0; |
| 302 | 302 | ||
| @@ -311,23 +311,23 @@ static int nl_pid_hash_rehash(struct nl_pid_hash *hash, int grow) | |||
| 311 | struct hlist_node *node, *tmp; | 311 | struct hlist_node *node, *tmp; |
| 312 | 312 | ||
| 313 | sk_for_each_safe(sk, node, tmp, &otable[i]) | 313 | sk_for_each_safe(sk, node, tmp, &otable[i]) |
| 314 | __sk_add_node(sk, nl_pid_hashfn(hash, nlk_sk(sk)->pid)); | 314 | __sk_add_node(sk, nl_portid_hashfn(hash, nlk_sk(sk)->portid)); |
| 315 | } | 315 | } |
| 316 | 316 | ||
| 317 | nl_pid_hash_free(otable, osize); | 317 | nl_portid_hash_free(otable, osize); |
| 318 | hash->rehash_time = jiffies + 10 * 60 * HZ; | 318 | hash->rehash_time = jiffies + 10 * 60 * HZ; |
| 319 | return 1; | 319 | return 1; |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | static inline int nl_pid_hash_dilute(struct nl_pid_hash *hash, int len) | 322 | static inline int nl_portid_hash_dilute(struct nl_portid_hash *hash, int len) |
| 323 | { | 323 | { |
| 324 | int avg = hash->entries >> hash->shift; | 324 | int avg = hash->entries >> hash->shift; |
| 325 | 325 | ||
| 326 | if (unlikely(avg > 1) && nl_pid_hash_rehash(hash, 1)) | 326 | if (unlikely(avg > 1) && nl_portid_hash_rehash(hash, 1)) |
| 327 | return 1; | 327 | return 1; |
| 328 | 328 | ||
| 329 | if (unlikely(len > avg) && time_after(jiffies, hash->rehash_time)) { | 329 | if (unlikely(len > avg) && time_after(jiffies, hash->rehash_time)) { |
| 330 | nl_pid_hash_rehash(hash, 0); | 330 | nl_portid_hash_rehash(hash, 0); |
| 331 | return 1; | 331 | return 1; |
| 332 | } | 332 | } |
| 333 | 333 | ||
| @@ -356,9 +356,9 @@ netlink_update_listeners(struct sock *sk) | |||
| 356 | * makes sure updates are visible before bind or setsockopt return. */ | 356 | * makes sure updates are visible before bind or setsockopt return. */ |
| 357 | } | 357 | } |
| 358 | 358 | ||
| 359 | static int netlink_insert(struct sock *sk, struct net *net, u32 pid) | 359 | static int netlink_insert(struct sock *sk, struct net *net, u32 portid) |
| 360 | { | 360 | { |
| 361 | struct nl_pid_hash *hash = &nl_table[sk->sk_protocol].hash; | 361 | struct nl_portid_hash *hash = &nl_table[sk->sk_protocol].hash; |
| 362 | struct hlist_head *head; | 362 | struct hlist_head *head; |
| 363 | int err = -EADDRINUSE; | 363 | int err = -EADDRINUSE; |
| 364 | struct sock *osk; | 364 | struct sock *osk; |
| @@ -366,10 +366,10 @@ static int netlink_insert(struct sock *sk, struct net *net, u32 pid) | |||
| 366 | int len; | 366 | int len; |
| 367 | 367 | ||
| 368 | netlink_table_grab(); | 368 | netlink_table_grab(); |
| 369 | head = nl_pid_hashfn(hash, pid); | 369 | head = nl_portid_hashfn(hash, portid); |
| 370 | len = 0; | 370 | len = 0; |
| 371 | sk_for_each(osk, node, head) { | 371 | sk_for_each(osk, node, head) { |
| 372 | if (net_eq(sock_net(osk), net) && (nlk_sk(osk)->pid == pid)) | 372 | if (net_eq(sock_net(osk), net) && (nlk_sk(osk)->portid == portid)) |
| 373 | break; | 373 | break; |
| 374 | len++; | 374 | len++; |
| 375 | } | 375 | } |
| @@ -377,17 +377,17 @@ static int netlink_insert(struct sock *sk, struct net *net, u32 pid) | |||
| 377 | goto err; | 377 | goto err; |
| 378 | 378 | ||
| 379 | err = -EBUSY; | 379 | err = -EBUSY; |
| 380 | if (nlk_sk(sk)->pid) | 380 | if (nlk_sk(sk)->portid) |
| 381 | goto err; | 381 | goto err; |
| 382 | 382 | ||
| 383 | err = -ENOMEM; | 383 | err = -ENOMEM; |
| 384 | if (BITS_PER_LONG > 32 && unlikely(hash->entries >= UINT_MAX)) | 384 | if (BITS_PER_LONG > 32 && unlikely(hash->entries >= UINT_MAX)) |
| 385 | goto err; | 385 | goto err; |
| 386 | 386 | ||
| 387 | if (len && nl_pid_hash_dilute(hash, len)) | 387 | if (len && nl_portid_hash_dilute(hash, len)) |
| 388 | head = nl_pid_hashfn(hash, pid); | 388 | head = nl_portid_hashfn(hash, portid); |
| 389 | hash->entries++; | 389 | hash->entries++; |
| 390 | nlk_sk(sk)->pid = pid; | 390 | nlk_sk(sk)->portid = portid; |
| 391 | sk_add_node(sk, head); | 391 | sk_add_node(sk, head); |
| 392 | err = 0; | 392 | err = 0; |
| 393 | 393 | ||
| @@ -518,11 +518,11 @@ static int netlink_release(struct socket *sock) | |||
| 518 | 518 | ||
| 519 | skb_queue_purge(&sk->sk_write_queue); | 519 | skb_queue_purge(&sk->sk_write_queue); |
| 520 | 520 | ||
| 521 | if (nlk->pid) { | 521 | if (nlk->portid) { |
| 522 | struct netlink_notify n = { | 522 | struct netlink_notify n = { |
| 523 | .net = sock_net(sk), | 523 | .net = sock_net(sk), |
| 524 | .protocol = sk->sk_protocol, | 524 | .protocol = sk->sk_protocol, |
| 525 | .pid = nlk->pid, | 525 | .portid = nlk->portid, |
| 526 | }; | 526 | }; |
| 527 | atomic_notifier_call_chain(&netlink_chain, | 527 | atomic_notifier_call_chain(&netlink_chain, |
| 528 | NETLINK_URELEASE, &n); | 528 | NETLINK_URELEASE, &n); |
| @@ -559,24 +559,24 @@ static int netlink_autobind(struct socket *sock) | |||
| 559 | { | 559 | { |
| 560 | struct sock *sk = sock->sk; | 560 | struct sock *sk = sock->sk; |
| 561 | struct net *net = sock_net(sk); | 561 | struct net *net = sock_net(sk); |
| 562 | struct nl_pid_hash *hash = &nl_table[sk->sk_protocol].hash; | 562 | struct nl_portid_hash *hash = &nl_table[sk->sk_protocol].hash; |
| 563 | struct hlist_head *head; | 563 | struct hlist_head *head; |
| 564 | struct sock *osk; | 564 | struct sock *osk; |
| 565 | struct hlist_node *node; | 565 | struct hlist_node *node; |
| 566 | s32 pid = task_tgid_vnr(current); | 566 | s32 portid = task_tgid_vnr(current); |
| 567 | int err; | 567 | int err; |
| 568 | static s32 rover = -4097; | 568 | static s32 rover = -4097; |
| 569 | 569 | ||
| 570 | retry: | 570 | retry: |
| 571 | cond_resched(); | 571 | cond_resched(); |
| 572 | netlink_table_grab(); | 572 | netlink_table_grab(); |
| 573 | head = nl_pid_hashfn(hash, pid); | 573 | head = nl_portid_hashfn(hash, portid); |
| 574 | sk_for_each(osk, node, head) { | 574 | sk_for_each(osk, node, head) { |
| 575 | if (!net_eq(sock_net(osk), net)) | 575 | if (!net_eq(sock_net(osk), net)) |
| 576 | continue; | 576 | continue; |
| 577 | if (nlk_sk(osk)->pid == pid) { | 577 | if (nlk_sk(osk)->portid == portid) { |
| 578 | /* Bind collision, search negative pid values. */ | 578 | /* Bind collision, search negative portid values. */ |
| 579 | pid = rover--; | 579 | portid = rover--; |
| 580 | if (rover > -4097) | 580 | if (rover > -4097) |
| 581 | rover = -4097; | 581 | rover = -4097; |
| 582 | netlink_table_ungrab(); | 582 | netlink_table_ungrab(); |
| @@ -585,7 +585,7 @@ retry: | |||
| 585 | } | 585 | } |
| 586 | netlink_table_ungrab(); | 586 | netlink_table_ungrab(); |
| 587 | 587 | ||
| 588 | err = netlink_insert(sk, net, pid); | 588 | err = netlink_insert(sk, net, portid); |
| 589 | if (err == -EADDRINUSE) | 589 | if (err == -EADDRINUSE) |
| 590 | goto retry; | 590 | goto retry; |
| 591 | 591 | ||
| @@ -668,8 +668,8 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, | |||
| 668 | return err; | 668 | return err; |
| 669 | } | 669 | } |
| 670 | 670 | ||
| 671 | if (nlk->pid) { | 671 | if (nlk->portid) { |
| 672 | if (nladdr->nl_pid != nlk->pid) | 672 | if (nladdr->nl_pid != nlk->portid) |
| 673 | return -EINVAL; | 673 | return -EINVAL; |
| 674 | } else { | 674 | } else { |
| 675 | err = nladdr->nl_pid ? | 675 | err = nladdr->nl_pid ? |
| @@ -715,7 +715,7 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr, | |||
| 715 | 715 | ||
| 716 | if (addr->sa_family == AF_UNSPEC) { | 716 | if (addr->sa_family == AF_UNSPEC) { |
| 717 | sk->sk_state = NETLINK_UNCONNECTED; | 717 | sk->sk_state = NETLINK_UNCONNECTED; |
| 718 | nlk->dst_pid = 0; | 718 | nlk->dst_portid = 0; |
| 719 | nlk->dst_group = 0; | 719 | nlk->dst_group = 0; |
| 720 | return 0; | 720 | return 0; |
| 721 | } | 721 | } |
| @@ -726,12 +726,12 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr, | |||
| 726 | if (nladdr->nl_groups && !netlink_capable(sock, NL_CFG_F_NONROOT_SEND)) | 726 | if (nladdr->nl_groups && !netlink_capable(sock, NL_CFG_F_NONROOT_SEND)) |
| 727 | return -EPERM; | 727 | return -EPERM; |
| 728 | 728 | ||
| 729 | if (!nlk->pid) | 729 | if (!nlk->portid) |
| 730 | err = netlink_autobind(sock); | 730 | err = netlink_autobind(sock); |
| 731 | 731 | ||
| 732 | if (err == 0) { | 732 | if (err == 0) { |
| 733 | sk->sk_state = NETLINK_CONNECTED; | 733 | sk->sk_state = NETLINK_CONNECTED; |
| 734 | nlk->dst_pid = nladdr->nl_pid; | 734 | nlk->dst_portid = nladdr->nl_pid; |
| 735 | nlk->dst_group = ffs(nladdr->nl_groups); | 735 | nlk->dst_group = ffs(nladdr->nl_groups); |
| 736 | } | 736 | } |
| 737 | 737 | ||
| @@ -750,10 +750,10 @@ static int netlink_getname(struct socket *sock, struct sockaddr *addr, | |||
| 750 | *addr_len = sizeof(*nladdr); | 750 | *addr_len = sizeof(*nladdr); |
| 751 | 751 | ||
| 752 | if (peer) { | 752 | if (peer) { |
| 753 | nladdr->nl_pid = nlk->dst_pid; | 753 | nladdr->nl_pid = nlk->dst_portid; |
| 754 | nladdr->nl_groups = netlink_group_mask(nlk->dst_group); | 754 | nladdr->nl_groups = netlink_group_mask(nlk->dst_group); |
| 755 | } else { | 755 | } else { |
| 756 | nladdr->nl_pid = nlk->pid; | 756 | nladdr->nl_pid = nlk->portid; |
| 757 | nladdr->nl_groups = nlk->groups ? nlk->groups[0] : 0; | 757 | nladdr->nl_groups = nlk->groups ? nlk->groups[0] : 0; |
| 758 | } | 758 | } |
| 759 | return 0; | 759 | return 0; |
| @@ -772,19 +772,19 @@ static void netlink_overrun(struct sock *sk) | |||
| 772 | atomic_inc(&sk->sk_drops); | 772 | atomic_inc(&sk->sk_drops); |
| 773 | } | 773 | } |
| 774 | 774 | ||
| 775 | static struct sock *netlink_getsockbypid(struct sock *ssk, u32 pid) | 775 | static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid) |
| 776 | { | 776 | { |
| 777 | struct sock *sock; | 777 | struct sock *sock; |
| 778 | struct netlink_sock *nlk; | 778 | struct netlink_sock *nlk; |
| 779 | 779 | ||
| 780 | sock = netlink_lookup(sock_net(ssk), ssk->sk_protocol, pid); | 780 | sock = netlink_lookup(sock_net(ssk), ssk->sk_protocol, portid); |
| 781 | if (!sock) | 781 | if (!sock) |
| 782 | return ERR_PTR(-ECONNREFUSED); | 782 | return ERR_PTR(-ECONNREFUSED); |
| 783 | 783 | ||
| 784 | /* Don't bother queuing skb if kernel socket has no input function */ | 784 | /* Don't bother queuing skb if kernel socket has no input function */ |
| 785 | nlk = nlk_sk(sock); | 785 | nlk = nlk_sk(sock); |
| 786 | if (sock->sk_state == NETLINK_CONNECTED && | 786 | if (sock->sk_state == NETLINK_CONNECTED && |
| 787 | nlk->dst_pid != nlk_sk(ssk)->pid) { | 787 | nlk->dst_portid != nlk_sk(ssk)->portid) { |
| 788 | sock_put(sock); | 788 | sock_put(sock); |
| 789 | return ERR_PTR(-ECONNREFUSED); | 789 | return ERR_PTR(-ECONNREFUSED); |
| 790 | } | 790 | } |
| @@ -935,7 +935,7 @@ static int netlink_unicast_kernel(struct sock *sk, struct sk_buff *skb, | |||
| 935 | } | 935 | } |
| 936 | 936 | ||
| 937 | int netlink_unicast(struct sock *ssk, struct sk_buff *skb, | 937 | int netlink_unicast(struct sock *ssk, struct sk_buff *skb, |
| 938 | u32 pid, int nonblock) | 938 | u32 portid, int nonblock) |
| 939 | { | 939 | { |
| 940 | struct sock *sk; | 940 | struct sock *sk; |
| 941 | int err; | 941 | int err; |
| @@ -945,7 +945,7 @@ int netlink_unicast(struct sock *ssk, struct sk_buff *skb, | |||
| 945 | 945 | ||
| 946 | timeo = sock_sndtimeo(ssk, nonblock); | 946 | timeo = sock_sndtimeo(ssk, nonblock); |
| 947 | retry: | 947 | retry: |
| 948 | sk = netlink_getsockbypid(ssk, pid); | 948 | sk = netlink_getsockbyportid(ssk, portid); |
| 949 | if (IS_ERR(sk)) { | 949 | if (IS_ERR(sk)) { |
| 950 | kfree_skb(skb); | 950 | kfree_skb(skb); |
| 951 | return PTR_ERR(sk); | 951 | return PTR_ERR(sk); |
| @@ -1005,7 +1005,7 @@ static int netlink_broadcast_deliver(struct sock *sk, struct sk_buff *skb) | |||
| 1005 | struct netlink_broadcast_data { | 1005 | struct netlink_broadcast_data { |
| 1006 | struct sock *exclude_sk; | 1006 | struct sock *exclude_sk; |
| 1007 | struct net *net; | 1007 | struct net *net; |
| 1008 | u32 pid; | 1008 | u32 portid; |
| 1009 | u32 group; | 1009 | u32 group; |
| 1010 | int failure; | 1010 | int failure; |
| 1011 | int delivery_failure; | 1011 | int delivery_failure; |
| @@ -1026,7 +1026,7 @@ static int do_one_broadcast(struct sock *sk, | |||
| 1026 | if (p->exclude_sk == sk) | 1026 | if (p->exclude_sk == sk) |
| 1027 | goto out; | 1027 | goto out; |
| 1028 | 1028 | ||
| 1029 | if (nlk->pid == p->pid || p->group - 1 >= nlk->ngroups || | 1029 | if (nlk->portid == p->portid || p->group - 1 >= nlk->ngroups || |
| 1030 | !test_bit(p->group - 1, nlk->groups)) | 1030 | !test_bit(p->group - 1, nlk->groups)) |
| 1031 | goto out; | 1031 | goto out; |
| 1032 | 1032 | ||
| @@ -1078,7 +1078,7 @@ out: | |||
| 1078 | return 0; | 1078 | return 0; |
| 1079 | } | 1079 | } |
| 1080 | 1080 | ||
| 1081 | int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 pid, | 1081 | int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 portid, |
| 1082 | u32 group, gfp_t allocation, | 1082 | u32 group, gfp_t allocation, |
| 1083 | int (*filter)(struct sock *dsk, struct sk_buff *skb, void *data), | 1083 | int (*filter)(struct sock *dsk, struct sk_buff *skb, void *data), |
| 1084 | void *filter_data) | 1084 | void *filter_data) |
| @@ -1092,7 +1092,7 @@ int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 pid, | |||
| 1092 | 1092 | ||
| 1093 | info.exclude_sk = ssk; | 1093 | info.exclude_sk = ssk; |
| 1094 | info.net = net; | 1094 | info.net = net; |
| 1095 | info.pid = pid; | 1095 | info.portid = portid; |
| 1096 | info.group = group; | 1096 | info.group = group; |
| 1097 | info.failure = 0; | 1097 | info.failure = 0; |
| 1098 | info.delivery_failure = 0; | 1098 | info.delivery_failure = 0; |
| @@ -1130,17 +1130,17 @@ int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 pid, | |||
| 1130 | } | 1130 | } |
| 1131 | EXPORT_SYMBOL(netlink_broadcast_filtered); | 1131 | EXPORT_SYMBOL(netlink_broadcast_filtered); |
| 1132 | 1132 | ||
| 1133 | int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid, | 1133 | int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 portid, |
| 1134 | u32 group, gfp_t allocation) | 1134 | u32 group, gfp_t allocation) |
| 1135 | { | 1135 | { |
| 1136 | return netlink_broadcast_filtered(ssk, skb, pid, group, allocation, | 1136 | return netlink_broadcast_filtered(ssk, skb, portid, group, allocation, |
| 1137 | NULL, NULL); | 1137 | NULL, NULL); |
| 1138 | } | 1138 | } |
| 1139 | EXPORT_SYMBOL(netlink_broadcast); | 1139 | EXPORT_SYMBOL(netlink_broadcast); |
| 1140 | 1140 | ||
| 1141 | struct netlink_set_err_data { | 1141 | struct netlink_set_err_data { |
| 1142 | struct sock *exclude_sk; | 1142 | struct sock *exclude_sk; |
| 1143 | u32 pid; | 1143 | u32 portid; |
| 1144 | u32 group; | 1144 | u32 group; |
| 1145 | int code; | 1145 | int code; |
| 1146 | }; | 1146 | }; |
| @@ -1156,7 +1156,7 @@ static int do_one_set_err(struct sock *sk, struct netlink_set_err_data *p) | |||
| 1156 | if (!net_eq(sock_net(sk), sock_net(p->exclude_sk))) | 1156 | if (!net_eq(sock_net(sk), sock_net(p->exclude_sk))) |
| 1157 | goto out; | 1157 | goto out; |
| 1158 | 1158 | ||
| 1159 | if (nlk->pid == p->pid || p->group - 1 >= nlk->ngroups || | 1159 | if (nlk->portid == p->portid || p->group - 1 >= nlk->ngroups || |
| 1160 | !test_bit(p->group - 1, nlk->groups)) | 1160 | !test_bit(p->group - 1, nlk->groups)) |
| 1161 | goto out; | 1161 | goto out; |
| 1162 | 1162 | ||
| @@ -1174,14 +1174,14 @@ out: | |||
| 1174 | /** | 1174 | /** |
| 1175 | * netlink_set_err - report error to broadcast listeners | 1175 | * netlink_set_err - report error to broadcast listeners |
| 1176 | * @ssk: the kernel netlink socket, as returned by netlink_kernel_create() | 1176 | * @ssk: the kernel netlink socket, as returned by netlink_kernel_create() |
| 1177 | * @pid: the PID of a process that we want to skip (if any) | 1177 | * @portid: the PORTID of a process that we want to skip (if any) |
| 1178 | * @groups: the broadcast group that will notice the error | 1178 | * @groups: the broadcast group that will notice the error |
| 1179 | * @code: error code, must be negative (as usual in kernelspace) | 1179 | * @code: error code, must be negative (as usual in kernelspace) |
| 1180 | * | 1180 | * |
| 1181 | * This function returns the number of broadcast listeners that have set the | 1181 | * This function returns the number of broadcast listeners that have set the |
| 1182 | * NETLINK_RECV_NO_ENOBUFS socket option. | 1182 | * NETLINK_RECV_NO_ENOBUFS socket option. |
| 1183 | */ | 1183 | */ |
| 1184 | int netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code) | 1184 | int netlink_set_err(struct sock *ssk, u32 portid, u32 group, int code) |
| 1185 | { | 1185 | { |
| 1186 | struct netlink_set_err_data info; | 1186 | struct netlink_set_err_data info; |
| 1187 | struct hlist_node *node; | 1187 | struct hlist_node *node; |
| @@ -1189,7 +1189,7 @@ int netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code) | |||
| 1189 | int ret = 0; | 1189 | int ret = 0; |
| 1190 | 1190 | ||
| 1191 | info.exclude_sk = ssk; | 1191 | info.exclude_sk = ssk; |
| 1192 | info.pid = pid; | 1192 | info.portid = portid; |
| 1193 | info.group = group; | 1193 | info.group = group; |
| 1194 | /* sk->sk_err wants a positive error value */ | 1194 | /* sk->sk_err wants a positive error value */ |
| 1195 | info.code = -code; | 1195 | info.code = -code; |
| @@ -1354,7 +1354,7 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
| 1354 | struct sock *sk = sock->sk; | 1354 | struct sock *sk = sock->sk; |
| 1355 | struct netlink_sock *nlk = nlk_sk(sk); | 1355 | struct netlink_sock *nlk = nlk_sk(sk); |
| 1356 | struct sockaddr_nl *addr = msg->msg_name; | 1356 | struct sockaddr_nl *addr = msg->msg_name; |
| 1357 | u32 dst_pid; | 1357 | u32 dst_portid; |
| 1358 | u32 dst_group; | 1358 | u32 dst_group; |
| 1359 | struct sk_buff *skb; | 1359 | struct sk_buff *skb; |
| 1360 | int err; | 1360 | int err; |
| @@ -1374,18 +1374,18 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
| 1374 | err = -EINVAL; | 1374 | err = -EINVAL; |
| 1375 | if (addr->nl_family != AF_NETLINK) | 1375 | if (addr->nl_family != AF_NETLINK) |
| 1376 | goto out; | 1376 | goto out; |
| 1377 | dst_pid = addr->nl_pid; | 1377 | dst_portid = addr->nl_pid; |
| 1378 | dst_group = ffs(addr->nl_groups); | 1378 | dst_group = ffs(addr->nl_groups); |
| 1379 | err = -EPERM; | 1379 | err = -EPERM; |
| 1380 | if ((dst_group || dst_pid) && | 1380 | if ((dst_group || dst_portid) && |
| 1381 | !netlink_capable(sock, NL_CFG_F_NONROOT_SEND)) | 1381 | !netlink_capable(sock, NL_CFG_F_NONROOT_SEND)) |
| 1382 | goto out; | 1382 | goto out; |
| 1383 | } else { | 1383 | } else { |
| 1384 | dst_pid = nlk->dst_pid; | 1384 | dst_portid = nlk->dst_portid; |
| 1385 | dst_group = nlk->dst_group; | 1385 | dst_group = nlk->dst_group; |
| 1386 | } | 1386 | } |
| 1387 | 1387 | ||
| 1388 | if (!nlk->pid) { | 1388 | if (!nlk->portid) { |
| 1389 | err = netlink_autobind(sock); | 1389 | err = netlink_autobind(sock); |
| 1390 | if (err) | 1390 | if (err) |
| 1391 | goto out; | 1391 | goto out; |
| @@ -1399,7 +1399,7 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
| 1399 | if (skb == NULL) | 1399 | if (skb == NULL) |
| 1400 | goto out; | 1400 | goto out; |
| 1401 | 1401 | ||
| 1402 | NETLINK_CB(skb).pid = nlk->pid; | 1402 | NETLINK_CB(skb).portid = nlk->portid; |
| 1403 | NETLINK_CB(skb).dst_group = dst_group; | 1403 | NETLINK_CB(skb).dst_group = dst_group; |
| 1404 | NETLINK_CB(skb).creds = siocb->scm->creds; | 1404 | NETLINK_CB(skb).creds = siocb->scm->creds; |
| 1405 | 1405 | ||
| @@ -1417,9 +1417,9 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
| 1417 | 1417 | ||
| 1418 | if (dst_group) { | 1418 | if (dst_group) { |
| 1419 | atomic_inc(&skb->users); | 1419 | atomic_inc(&skb->users); |
| 1420 | netlink_broadcast(sk, skb, dst_pid, dst_group, GFP_KERNEL); | 1420 | netlink_broadcast(sk, skb, dst_portid, dst_group, GFP_KERNEL); |
| 1421 | } | 1421 | } |
| 1422 | err = netlink_unicast(sk, skb, dst_pid, msg->msg_flags&MSG_DONTWAIT); | 1422 | err = netlink_unicast(sk, skb, dst_portid, msg->msg_flags&MSG_DONTWAIT); |
| 1423 | 1423 | ||
| 1424 | out: | 1424 | out: |
| 1425 | scm_destroy(siocb->scm); | 1425 | scm_destroy(siocb->scm); |
| @@ -1482,7 +1482,7 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock, | |||
| 1482 | struct sockaddr_nl *addr = (struct sockaddr_nl *)msg->msg_name; | 1482 | struct sockaddr_nl *addr = (struct sockaddr_nl *)msg->msg_name; |
| 1483 | addr->nl_family = AF_NETLINK; | 1483 | addr->nl_family = AF_NETLINK; |
| 1484 | addr->nl_pad = 0; | 1484 | addr->nl_pad = 0; |
| 1485 | addr->nl_pid = NETLINK_CB(skb).pid; | 1485 | addr->nl_pid = NETLINK_CB(skb).portid; |
| 1486 | addr->nl_groups = netlink_group_mask(NETLINK_CB(skb).dst_group); | 1486 | addr->nl_groups = netlink_group_mask(NETLINK_CB(skb).dst_group); |
| 1487 | msg->msg_namelen = sizeof(*addr); | 1487 | msg->msg_namelen = sizeof(*addr); |
| 1488 | } | 1488 | } |
| @@ -1683,7 +1683,7 @@ void netlink_clear_multicast_users(struct sock *ksk, unsigned int group) | |||
| 1683 | } | 1683 | } |
| 1684 | 1684 | ||
| 1685 | struct nlmsghdr * | 1685 | struct nlmsghdr * |
| 1686 | __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags) | 1686 | __nlmsg_put(struct sk_buff *skb, u32 portid, u32 seq, int type, int len, int flags) |
| 1687 | { | 1687 | { |
| 1688 | struct nlmsghdr *nlh; | 1688 | struct nlmsghdr *nlh; |
| 1689 | int size = NLMSG_LENGTH(len); | 1689 | int size = NLMSG_LENGTH(len); |
| @@ -1692,7 +1692,7 @@ __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags) | |||
| 1692 | nlh->nlmsg_type = type; | 1692 | nlh->nlmsg_type = type; |
| 1693 | nlh->nlmsg_len = size; | 1693 | nlh->nlmsg_len = size; |
| 1694 | nlh->nlmsg_flags = flags; | 1694 | nlh->nlmsg_flags = flags; |
| 1695 | nlh->nlmsg_pid = pid; | 1695 | nlh->nlmsg_pid = portid; |
| 1696 | nlh->nlmsg_seq = seq; | 1696 | nlh->nlmsg_seq = seq; |
| 1697 | if (!__builtin_constant_p(size) || NLMSG_ALIGN(size) - size != 0) | 1697 | if (!__builtin_constant_p(size) || NLMSG_ALIGN(size) - size != 0) |
| 1698 | memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size); | 1698 | memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size); |
| @@ -1788,7 +1788,7 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, | |||
| 1788 | atomic_inc(&skb->users); | 1788 | atomic_inc(&skb->users); |
| 1789 | cb->skb = skb; | 1789 | cb->skb = skb; |
| 1790 | 1790 | ||
| 1791 | sk = netlink_lookup(sock_net(ssk), ssk->sk_protocol, NETLINK_CB(skb).pid); | 1791 | sk = netlink_lookup(sock_net(ssk), ssk->sk_protocol, NETLINK_CB(skb).portid); |
| 1792 | if (sk == NULL) { | 1792 | if (sk == NULL) { |
| 1793 | netlink_destroy_callback(cb); | 1793 | netlink_destroy_callback(cb); |
| 1794 | return -ECONNREFUSED; | 1794 | return -ECONNREFUSED; |
| @@ -1836,7 +1836,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err) | |||
| 1836 | 1836 | ||
| 1837 | sk = netlink_lookup(sock_net(in_skb->sk), | 1837 | sk = netlink_lookup(sock_net(in_skb->sk), |
| 1838 | in_skb->sk->sk_protocol, | 1838 | in_skb->sk->sk_protocol, |
| 1839 | NETLINK_CB(in_skb).pid); | 1839 | NETLINK_CB(in_skb).portid); |
| 1840 | if (sk) { | 1840 | if (sk) { |
| 1841 | sk->sk_err = ENOBUFS; | 1841 | sk->sk_err = ENOBUFS; |
| 1842 | sk->sk_error_report(sk); | 1842 | sk->sk_error_report(sk); |
| @@ -1845,12 +1845,12 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err) | |||
| 1845 | return; | 1845 | return; |
| 1846 | } | 1846 | } |
| 1847 | 1847 | ||
| 1848 | rep = __nlmsg_put(skb, NETLINK_CB(in_skb).pid, nlh->nlmsg_seq, | 1848 | rep = __nlmsg_put(skb, NETLINK_CB(in_skb).portid, nlh->nlmsg_seq, |
| 1849 | NLMSG_ERROR, payload, 0); | 1849 | NLMSG_ERROR, payload, 0); |
| 1850 | errmsg = nlmsg_data(rep); | 1850 | errmsg = nlmsg_data(rep); |
| 1851 | errmsg->error = err; | 1851 | errmsg->error = err; |
| 1852 | memcpy(&errmsg->msg, nlh, err ? nlh->nlmsg_len : sizeof(*nlh)); | 1852 | memcpy(&errmsg->msg, nlh, err ? nlh->nlmsg_len : sizeof(*nlh)); |
| 1853 | netlink_unicast(in_skb->sk, skb, NETLINK_CB(in_skb).pid, MSG_DONTWAIT); | 1853 | netlink_unicast(in_skb->sk, skb, NETLINK_CB(in_skb).portid, MSG_DONTWAIT); |
| 1854 | } | 1854 | } |
| 1855 | EXPORT_SYMBOL(netlink_ack); | 1855 | EXPORT_SYMBOL(netlink_ack); |
| 1856 | 1856 | ||
| @@ -1900,33 +1900,33 @@ EXPORT_SYMBOL(netlink_rcv_skb); | |||
| 1900 | * nlmsg_notify - send a notification netlink message | 1900 | * nlmsg_notify - send a notification netlink message |
| 1901 | * @sk: netlink socket to use | 1901 | * @sk: netlink socket to use |
| 1902 | * @skb: notification message | 1902 | * @skb: notification message |
| 1903 | * @pid: destination netlink pid for reports or 0 | 1903 | * @portid: destination netlink portid for reports or 0 |
| 1904 | * @group: destination multicast group or 0 | 1904 | * @group: destination multicast group or 0 |
| 1905 | * @report: 1 to report back, 0 to disable | 1905 | * @report: 1 to report back, 0 to disable |
| 1906 | * @flags: allocation flags | 1906 | * @flags: allocation flags |
| 1907 | */ | 1907 | */ |
| 1908 | int nlmsg_notify(struct sock *sk, struct sk_buff *skb, u32 pid, | 1908 | int nlmsg_notify(struct sock *sk, struct sk_buff *skb, u32 portid, |
| 1909 | unsigned int group, int report, gfp_t flags) | 1909 | unsigned int group, int report, gfp_t flags) |
| 1910 | { | 1910 | { |
| 1911 | int err = 0; | 1911 | int err = 0; |
| 1912 | 1912 | ||
| 1913 | if (group) { | 1913 | if (group) { |
| 1914 | int exclude_pid = 0; | 1914 | int exclude_portid = 0; |
| 1915 | 1915 | ||
| 1916 | if (report) { | 1916 | if (report) { |
| 1917 | atomic_inc(&skb->users); | 1917 | atomic_inc(&skb->users); |
| 1918 | exclude_pid = pid; | 1918 | exclude_portid = portid; |
| 1919 | } | 1919 | } |
| 1920 | 1920 | ||
| 1921 | /* errors reported via destination sk->sk_err, but propagate | 1921 | /* errors reported via destination sk->sk_err, but propagate |
| 1922 | * delivery errors if NETLINK_BROADCAST_ERROR flag is set */ | 1922 | * delivery errors if NETLINK_BROADCAST_ERROR flag is set */ |
| 1923 | err = nlmsg_multicast(sk, skb, exclude_pid, group, flags); | 1923 | err = nlmsg_multicast(sk, skb, exclude_portid, group, flags); |
| 1924 | } | 1924 | } |
| 1925 | 1925 | ||
| 1926 | if (report) { | 1926 | if (report) { |
| 1927 | int err2; | 1927 | int err2; |
| 1928 | 1928 | ||
| 1929 | err2 = nlmsg_unicast(sk, skb, pid); | 1929 | err2 = nlmsg_unicast(sk, skb, portid); |
| 1930 | if (!err || err == -ESRCH) | 1930 | if (!err || err == -ESRCH) |
| 1931 | err = err2; | 1931 | err = err2; |
| 1932 | } | 1932 | } |
| @@ -1951,7 +1951,7 @@ static struct sock *netlink_seq_socket_idx(struct seq_file *seq, loff_t pos) | |||
| 1951 | loff_t off = 0; | 1951 | loff_t off = 0; |
| 1952 | 1952 | ||
| 1953 | for (i = 0; i < MAX_LINKS; i++) { | 1953 | for (i = 0; i < MAX_LINKS; i++) { |
| 1954 | struct nl_pid_hash *hash = &nl_table[i].hash; | 1954 | struct nl_portid_hash *hash = &nl_table[i].hash; |
| 1955 | 1955 | ||
| 1956 | for (j = 0; j <= hash->mask; j++) { | 1956 | for (j = 0; j <= hash->mask; j++) { |
| 1957 | sk_for_each(s, node, &hash->table[j]) { | 1957 | sk_for_each(s, node, &hash->table[j]) { |
| @@ -1999,7 +1999,7 @@ static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
| 1999 | j = iter->hash_idx + 1; | 1999 | j = iter->hash_idx + 1; |
| 2000 | 2000 | ||
| 2001 | do { | 2001 | do { |
| 2002 | struct nl_pid_hash *hash = &nl_table[i].hash; | 2002 | struct nl_portid_hash *hash = &nl_table[i].hash; |
| 2003 | 2003 | ||
| 2004 | for (; j <= hash->mask; j++) { | 2004 | for (; j <= hash->mask; j++) { |
| 2005 | s = sk_head(&hash->table[j]); | 2005 | s = sk_head(&hash->table[j]); |
| @@ -2038,7 +2038,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v) | |||
| 2038 | seq_printf(seq, "%pK %-3d %-6d %08x %-8d %-8d %pK %-8d %-8d %-8lu\n", | 2038 | seq_printf(seq, "%pK %-3d %-6d %08x %-8d %-8d %pK %-8d %-8d %-8lu\n", |
| 2039 | s, | 2039 | s, |
| 2040 | s->sk_protocol, | 2040 | s->sk_protocol, |
| 2041 | nlk->pid, | 2041 | nlk->portid, |
| 2042 | nlk->groups ? (u32)nlk->groups[0] : 0, | 2042 | nlk->groups ? (u32)nlk->groups[0] : 0, |
| 2043 | sk_rmem_alloc_get(s), | 2043 | sk_rmem_alloc_get(s), |
| 2044 | sk_wmem_alloc_get(s), | 2044 | sk_wmem_alloc_get(s), |
| @@ -2183,12 +2183,12 @@ static int __init netlink_proto_init(void) | |||
| 2183 | order = get_bitmask_order(min(limit, (unsigned long)UINT_MAX)) - 1; | 2183 | order = get_bitmask_order(min(limit, (unsigned long)UINT_MAX)) - 1; |
| 2184 | 2184 | ||
| 2185 | for (i = 0; i < MAX_LINKS; i++) { | 2185 | for (i = 0; i < MAX_LINKS; i++) { |
| 2186 | struct nl_pid_hash *hash = &nl_table[i].hash; | 2186 | struct nl_portid_hash *hash = &nl_table[i].hash; |
| 2187 | 2187 | ||
| 2188 | hash->table = nl_pid_hash_zalloc(1 * sizeof(*hash->table)); | 2188 | hash->table = nl_portid_hash_zalloc(1 * sizeof(*hash->table)); |
| 2189 | if (!hash->table) { | 2189 | if (!hash->table) { |
| 2190 | while (i-- > 0) | 2190 | while (i-- > 0) |
| 2191 | nl_pid_hash_free(nl_table[i].hash.table, | 2191 | nl_portid_hash_free(nl_table[i].hash.table, |
| 2192 | 1 * sizeof(*hash->table)); | 2192 | 1 * sizeof(*hash->table)); |
| 2193 | kfree(nl_table); | 2193 | kfree(nl_table); |
| 2194 | goto panic; | 2194 | goto panic; |
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index 19288b7d613..f2aabb6f410 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c | |||
| @@ -501,7 +501,7 @@ EXPORT_SYMBOL(genl_unregister_family); | |||
| 501 | /** | 501 | /** |
| 502 | * genlmsg_put - Add generic netlink header to netlink message | 502 | * genlmsg_put - Add generic netlink header to netlink message |
| 503 | * @skb: socket buffer holding the message | 503 | * @skb: socket buffer holding the message |
| 504 | * @pid: netlink pid the message is addressed to | 504 | * @portid: netlink portid the message is addressed to |
| 505 | * @seq: sequence number (usually the one of the sender) | 505 | * @seq: sequence number (usually the one of the sender) |
| 506 | * @family: generic netlink family | 506 | * @family: generic netlink family |
| 507 | * @flags: netlink message flags | 507 | * @flags: netlink message flags |
| @@ -509,13 +509,13 @@ EXPORT_SYMBOL(genl_unregister_family); | |||
| 509 | * | 509 | * |
| 510 | * Returns pointer to user specific header | 510 | * Returns pointer to user specific header |
| 511 | */ | 511 | */ |
| 512 | void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, | 512 | void *genlmsg_put(struct sk_buff *skb, u32 portid, u32 seq, |
| 513 | struct genl_family *family, int flags, u8 cmd) | 513 | struct genl_family *family, int flags, u8 cmd) |
| 514 | { | 514 | { |
| 515 | struct nlmsghdr *nlh; | 515 | struct nlmsghdr *nlh; |
| 516 | struct genlmsghdr *hdr; | 516 | struct genlmsghdr *hdr; |
| 517 | 517 | ||
| 518 | nlh = nlmsg_put(skb, pid, seq, family->id, GENL_HDRLEN + | 518 | nlh = nlmsg_put(skb, portid, seq, family->id, GENL_HDRLEN + |
| 519 | family->hdrsize, flags); | 519 | family->hdrsize, flags); |
| 520 | if (nlh == NULL) | 520 | if (nlh == NULL) |
| 521 | return NULL; | 521 | return NULL; |
| @@ -585,7 +585,7 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
| 585 | } | 585 | } |
| 586 | 586 | ||
| 587 | info.snd_seq = nlh->nlmsg_seq; | 587 | info.snd_seq = nlh->nlmsg_seq; |
| 588 | info.snd_pid = NETLINK_CB(skb).pid; | 588 | info.snd_portid = NETLINK_CB(skb).portid; |
| 589 | info.nlhdr = nlh; | 589 | info.nlhdr = nlh; |
| 590 | info.genlhdr = nlmsg_data(nlh); | 590 | info.genlhdr = nlmsg_data(nlh); |
| 591 | info.userhdr = nlmsg_data(nlh) + GENL_HDRLEN; | 591 | info.userhdr = nlmsg_data(nlh) + GENL_HDRLEN; |
| @@ -626,12 +626,12 @@ static struct genl_family genl_ctrl = { | |||
| 626 | .netnsok = true, | 626 | .netnsok = true, |
| 627 | }; | 627 | }; |
| 628 | 628 | ||
| 629 | static int ctrl_fill_info(struct genl_family *family, u32 pid, u32 seq, | 629 | static int ctrl_fill_info(struct genl_family *family, u32 portid, u32 seq, |
| 630 | u32 flags, struct sk_buff *skb, u8 cmd) | 630 | u32 flags, struct sk_buff *skb, u8 cmd) |
| 631 | { | 631 | { |
| 632 | void *hdr; | 632 | void *hdr; |
| 633 | 633 | ||
| 634 | hdr = genlmsg_put(skb, pid, seq, &genl_ctrl, flags, cmd); | 634 | hdr = genlmsg_put(skb, portid, seq, &genl_ctrl, flags, cmd); |
| 635 | if (hdr == NULL) | 635 | if (hdr == NULL) |
| 636 | return -1; | 636 | return -1; |
| 637 | 637 | ||
| @@ -701,7 +701,7 @@ nla_put_failure: | |||
| 701 | return -EMSGSIZE; | 701 | return -EMSGSIZE; |
| 702 | } | 702 | } |
| 703 | 703 | ||
| 704 | static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 pid, | 704 | static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 portid, |
| 705 | u32 seq, u32 flags, struct sk_buff *skb, | 705 | u32 seq, u32 flags, struct sk_buff *skb, |
| 706 | u8 cmd) | 706 | u8 cmd) |
| 707 | { | 707 | { |
| @@ -709,7 +709,7 @@ static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 pid, | |||
| 709 | struct nlattr *nla_grps; | 709 | struct nlattr *nla_grps; |
| 710 | struct nlattr *nest; | 710 | struct nlattr *nest; |
| 711 | 711 | ||
| 712 | hdr = genlmsg_put(skb, pid, seq, &genl_ctrl, flags, cmd); | 712 | hdr = genlmsg_put(skb, portid, seq, &genl_ctrl, flags, cmd); |
| 713 | if (hdr == NULL) | 713 | if (hdr == NULL) |
| 714 | return -1; | 714 | return -1; |
| 715 | 715 | ||
| @@ -756,7 +756,7 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 756 | continue; | 756 | continue; |
| 757 | if (++n < fams_to_skip) | 757 | if (++n < fams_to_skip) |
| 758 | continue; | 758 | continue; |
| 759 | if (ctrl_fill_info(rt, NETLINK_CB(cb->skb).pid, | 759 | if (ctrl_fill_info(rt, NETLINK_CB(cb->skb).portid, |
| 760 | cb->nlh->nlmsg_seq, NLM_F_MULTI, | 760 | cb->nlh->nlmsg_seq, NLM_F_MULTI, |
| 761 | skb, CTRL_CMD_NEWFAMILY) < 0) | 761 | skb, CTRL_CMD_NEWFAMILY) < 0) |
| 762 | goto errout; | 762 | goto errout; |
| @@ -773,7 +773,7 @@ errout: | |||
| 773 | } | 773 | } |
| 774 | 774 | ||
| 775 | static struct sk_buff *ctrl_build_family_msg(struct genl_family *family, | 775 | static struct sk_buff *ctrl_build_family_msg(struct genl_family *family, |
| 776 | u32 pid, int seq, u8 cmd) | 776 | u32 portid, int seq, u8 cmd) |
| 777 | { | 777 | { |
| 778 | struct sk_buff *skb; | 778 | struct sk_buff *skb; |
| 779 | int err; | 779 | int err; |
| @@ -782,7 +782,7 @@ static struct sk_buff *ctrl_build_family_msg(struct genl_family *family, | |||
| 782 | if (skb == NULL) | 782 | if (skb == NULL) |
| 783 | return ERR_PTR(-ENOBUFS); | 783 | return ERR_PTR(-ENOBUFS); |
| 784 | 784 | ||
| 785 | err = ctrl_fill_info(family, pid, seq, 0, skb, cmd); | 785 | err = ctrl_fill_info(family, portid, seq, 0, skb, cmd); |
| 786 | if (err < 0) { | 786 | if (err < 0) { |
| 787 | nlmsg_free(skb); | 787 | nlmsg_free(skb); |
| 788 | return ERR_PTR(err); | 788 | return ERR_PTR(err); |
| @@ -792,7 +792,7 @@ static struct sk_buff *ctrl_build_family_msg(struct genl_family *family, | |||
| 792 | } | 792 | } |
| 793 | 793 | ||
| 794 | static struct sk_buff *ctrl_build_mcgrp_msg(struct genl_multicast_group *grp, | 794 | static struct sk_buff *ctrl_build_mcgrp_msg(struct genl_multicast_group *grp, |
| 795 | u32 pid, int seq, u8 cmd) | 795 | u32 portid, int seq, u8 cmd) |
| 796 | { | 796 | { |
| 797 | struct sk_buff *skb; | 797 | struct sk_buff *skb; |
| 798 | int err; | 798 | int err; |
| @@ -801,7 +801,7 @@ static struct sk_buff *ctrl_build_mcgrp_msg(struct genl_multicast_group *grp, | |||
| 801 | if (skb == NULL) | 801 | if (skb == NULL) |
| 802 | return ERR_PTR(-ENOBUFS); | 802 | return ERR_PTR(-ENOBUFS); |
| 803 | 803 | ||
| 804 | err = ctrl_fill_mcgrp_info(grp, pid, seq, 0, skb, cmd); | 804 | err = ctrl_fill_mcgrp_info(grp, portid, seq, 0, skb, cmd); |
| 805 | if (err < 0) { | 805 | if (err < 0) { |
| 806 | nlmsg_free(skb); | 806 | nlmsg_free(skb); |
| 807 | return ERR_PTR(err); | 807 | return ERR_PTR(err); |
| @@ -853,7 +853,7 @@ static int ctrl_getfamily(struct sk_buff *skb, struct genl_info *info) | |||
| 853 | return -ENOENT; | 853 | return -ENOENT; |
| 854 | } | 854 | } |
| 855 | 855 | ||
| 856 | msg = ctrl_build_family_msg(res, info->snd_pid, info->snd_seq, | 856 | msg = ctrl_build_family_msg(res, info->snd_portid, info->snd_seq, |
| 857 | CTRL_CMD_NEWFAMILY); | 857 | CTRL_CMD_NEWFAMILY); |
| 858 | if (IS_ERR(msg)) | 858 | if (IS_ERR(msg)) |
| 859 | return PTR_ERR(msg); | 859 | return PTR_ERR(msg); |
| @@ -971,7 +971,7 @@ problem: | |||
| 971 | 971 | ||
| 972 | subsys_initcall(genl_init); | 972 | subsys_initcall(genl_init); |
| 973 | 973 | ||
| 974 | static int genlmsg_mcast(struct sk_buff *skb, u32 pid, unsigned long group, | 974 | static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group, |
| 975 | gfp_t flags) | 975 | gfp_t flags) |
| 976 | { | 976 | { |
| 977 | struct sk_buff *tmp; | 977 | struct sk_buff *tmp; |
| @@ -986,7 +986,7 @@ static int genlmsg_mcast(struct sk_buff *skb, u32 pid, unsigned long group, | |||
| 986 | goto error; | 986 | goto error; |
| 987 | } | 987 | } |
| 988 | err = nlmsg_multicast(prev->genl_sock, tmp, | 988 | err = nlmsg_multicast(prev->genl_sock, tmp, |
| 989 | pid, group, flags); | 989 | portid, group, flags); |
| 990 | if (err) | 990 | if (err) |
| 991 | goto error; | 991 | goto error; |
| 992 | } | 992 | } |
| @@ -994,20 +994,20 @@ static int genlmsg_mcast(struct sk_buff *skb, u32 pid, unsigned long group, | |||
| 994 | prev = net; | 994 | prev = net; |
| 995 | } | 995 | } |
| 996 | 996 | ||
| 997 | return nlmsg_multicast(prev->genl_sock, skb, pid, group, flags); | 997 | return nlmsg_multicast(prev->genl_sock, skb, portid, group, flags); |
| 998 | error: | 998 | error: |
| 999 | kfree_skb(skb); | 999 | kfree_skb(skb); |
| 1000 | return err; | 1000 | return err; |
| 1001 | } | 1001 | } |
| 1002 | 1002 | ||
| 1003 | int genlmsg_multicast_allns(struct sk_buff *skb, u32 pid, unsigned int group, | 1003 | int genlmsg_multicast_allns(struct sk_buff *skb, u32 portid, unsigned int group, |
| 1004 | gfp_t flags) | 1004 | gfp_t flags) |
| 1005 | { | 1005 | { |
| 1006 | return genlmsg_mcast(skb, pid, group, flags); | 1006 | return genlmsg_mcast(skb, portid, group, flags); |
| 1007 | } | 1007 | } |
| 1008 | EXPORT_SYMBOL(genlmsg_multicast_allns); | 1008 | EXPORT_SYMBOL(genlmsg_multicast_allns); |
| 1009 | 1009 | ||
| 1010 | void genl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group, | 1010 | void genl_notify(struct sk_buff *skb, struct net *net, u32 portid, u32 group, |
| 1011 | struct nlmsghdr *nlh, gfp_t flags) | 1011 | struct nlmsghdr *nlh, gfp_t flags) |
| 1012 | { | 1012 | { |
| 1013 | struct sock *sk = net->genl_sock; | 1013 | struct sock *sk = net->genl_sock; |
| @@ -1016,6 +1016,6 @@ void genl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group, | |||
| 1016 | if (nlh) | 1016 | if (nlh) |
| 1017 | report = nlmsg_report(nlh); | 1017 | report = nlmsg_report(nlh); |
| 1018 | 1018 | ||
| 1019 | nlmsg_notify(sk, skb, pid, group, report, flags); | 1019 | nlmsg_notify(sk, skb, portid, group, report, flags); |
| 1020 | } | 1020 | } |
| 1021 | EXPORT_SYMBOL(genl_notify); | 1021 | EXPORT_SYMBOL(genl_notify); |
