Skip to content

Commit 15e4730

Browse files
ebiedermdavem330
authored andcommitted
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" <[email protected]> Acked-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9f00d97 commit 15e4730

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+728
-728
lines changed

crypto/crypto_user.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static int crypto_report_alg(struct crypto_alg *alg,
166166
struct crypto_user_alg *ualg;
167167
int err = 0;
168168

169-
nlh = nlmsg_put(skb, NETLINK_CB(in_skb).pid, info->nlmsg_seq,
169+
nlh = nlmsg_put(skb, NETLINK_CB(in_skb).portid, info->nlmsg_seq,
170170
CRYPTO_MSG_GETALG, sizeof(*ualg), info->nlmsg_flags);
171171
if (!nlh) {
172172
err = -EMSGSIZE;
@@ -216,7 +216,7 @@ static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
216216
if (err)
217217
return err;
218218

219-
return nlmsg_unicast(crypto_nlsk, skb, NETLINK_CB(in_skb).pid);
219+
return nlmsg_unicast(crypto_nlsk, skb, NETLINK_CB(in_skb).portid);
220220
}
221221

222222
static int crypto_dump_report(struct sk_buff *skb, struct netlink_callback *cb)

drivers/net/team/team.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,7 @@ static int team_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info)
18861886
if (!msg)
18871887
return -ENOMEM;
18881888

1889-
hdr = genlmsg_put(msg, info->snd_pid, info->snd_seq,
1889+
hdr = genlmsg_put(msg, info->snd_portid, info->snd_seq,
18901890
&team_nl_family, 0, TEAM_CMD_NOOP);
18911891
if (IS_ERR(hdr)) {
18921892
err = PTR_ERR(hdr);
@@ -1895,7 +1895,7 @@ static int team_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info)
18951895

18961896
genlmsg_end(msg, hdr);
18971897

1898-
return genlmsg_unicast(genl_info_net(info), msg, info->snd_pid);
1898+
return genlmsg_unicast(genl_info_net(info), msg, info->snd_portid);
18991899

19001900
err_msg_put:
19011901
nlmsg_free(msg);
@@ -1952,7 +1952,7 @@ static int team_nl_send_generic(struct genl_info *info, struct team *team,
19521952
if (err < 0)
19531953
goto err_fill;
19541954

1955-
err = genlmsg_unicast(genl_info_net(info), skb, info->snd_pid);
1955+
err = genlmsg_unicast(genl_info_net(info), skb, info->snd_portid);
19561956
return err;
19571957

19581958
err_fill:
@@ -1961,11 +1961,11 @@ static int team_nl_send_generic(struct genl_info *info, struct team *team,
19611961
}
19621962

19631963
typedef int team_nl_send_func_t(struct sk_buff *skb,
1964-
struct team *team, u32 pid);
1964+
struct team *team, u32 portid);
19651965

1966-
static int team_nl_send_unicast(struct sk_buff *skb, struct team *team, u32 pid)
1966+
static int team_nl_send_unicast(struct sk_buff *skb, struct team *team, u32 portid)
19671967
{
1968-
return genlmsg_unicast(dev_net(team->dev), skb, pid);
1968+
return genlmsg_unicast(dev_net(team->dev), skb, portid);
19691969
}
19701970

19711971
static int team_nl_fill_one_option_get(struct sk_buff *skb, struct team *team,
@@ -2050,13 +2050,13 @@ static int team_nl_fill_one_option_get(struct sk_buff *skb, struct team *team,
20502050
}
20512051

20522052
static int __send_and_alloc_skb(struct sk_buff **pskb,
2053-
struct team *team, u32 pid,
2053+
struct team *team, u32 portid,
20542054
team_nl_send_func_t *send_func)
20552055
{
20562056
int err;
20572057

20582058
if (*pskb) {
2059-
err = send_func(*pskb, team, pid);
2059+
err = send_func(*pskb, team, portid);
20602060
if (err)
20612061
return err;
20622062
}
@@ -2066,7 +2066,7 @@ static int __send_and_alloc_skb(struct sk_buff **pskb,
20662066
return 0;
20672067
}
20682068

2069-
static int team_nl_send_options_get(struct team *team, u32 pid, u32 seq,
2069+
static int team_nl_send_options_get(struct team *team, u32 portid, u32 seq,
20702070
int flags, team_nl_send_func_t *send_func,
20712071
struct list_head *sel_opt_inst_list)
20722072
{
@@ -2083,11 +2083,11 @@ static int team_nl_send_options_get(struct team *team, u32 pid, u32 seq,
20832083
struct team_option_inst, tmp_list);
20842084

20852085
start_again:
2086-
err = __send_and_alloc_skb(&skb, team, pid, send_func);
2086+
err = __send_and_alloc_skb(&skb, team, portid, send_func);
20872087
if (err)
20882088
return err;
20892089

2090-
hdr = genlmsg_put(skb, pid, seq, &team_nl_family, flags | NLM_F_MULTI,
2090+
hdr = genlmsg_put(skb, portid, seq, &team_nl_family, flags | NLM_F_MULTI,
20912091
TEAM_CMD_OPTIONS_GET);
20922092
if (IS_ERR(hdr))
20932093
return PTR_ERR(hdr);
@@ -2120,15 +2120,15 @@ static int team_nl_send_options_get(struct team *team, u32 pid, u32 seq,
21202120
goto start_again;
21212121

21222122
send_done:
2123-
nlh = nlmsg_put(skb, pid, seq, NLMSG_DONE, 0, flags | NLM_F_MULTI);
2123+
nlh = nlmsg_put(skb, portid, seq, NLMSG_DONE, 0, flags | NLM_F_MULTI);
21242124
if (!nlh) {
2125-
err = __send_and_alloc_skb(&skb, team, pid, send_func);
2125+
err = __send_and_alloc_skb(&skb, team, portid, send_func);
21262126
if (err)
21272127
goto errout;
21282128
goto send_done;
21292129
}
21302130

2131-
return send_func(skb, team, pid);
2131+
return send_func(skb, team, portid);
21322132

21332133
nla_put_failure:
21342134
err = -EMSGSIZE;
@@ -2151,7 +2151,7 @@ static int team_nl_cmd_options_get(struct sk_buff *skb, struct genl_info *info)
21512151

21522152
list_for_each_entry(opt_inst, &team->option_inst_list, list)
21532153
list_add_tail(&opt_inst->tmp_list, &sel_opt_inst_list);
2154-
err = team_nl_send_options_get(team, info->snd_pid, info->snd_seq,
2154+
err = team_nl_send_options_get(team, info->snd_portid, info->snd_seq,
21552155
NLM_F_ACK, team_nl_send_unicast,
21562156
&sel_opt_inst_list);
21572157

@@ -2305,15 +2305,15 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
23052305
}
23062306

23072307
static int team_nl_fill_port_list_get(struct sk_buff *skb,
2308-
u32 pid, u32 seq, int flags,
2308+
u32 portid, u32 seq, int flags,
23092309
struct team *team,
23102310
bool fillall)
23112311
{
23122312
struct nlattr *port_list;
23132313
void *hdr;
23142314
struct team_port *port;
23152315

2316-
hdr = genlmsg_put(skb, pid, seq, &team_nl_family, flags,
2316+
hdr = genlmsg_put(skb, portid, seq, &team_nl_family, flags,
23172317
TEAM_CMD_PORT_LIST_GET);
23182318
if (IS_ERR(hdr))
23192319
return PTR_ERR(hdr);
@@ -2362,7 +2362,7 @@ static int team_nl_fill_port_list_get_all(struct sk_buff *skb,
23622362
struct genl_info *info, int flags,
23632363
struct team *team)
23642364
{
2365-
return team_nl_fill_port_list_get(skb, info->snd_pid,
2365+
return team_nl_fill_port_list_get(skb, info->snd_portid,
23662366
info->snd_seq, NLM_F_ACK,
23672367
team, true);
23682368
}
@@ -2415,7 +2415,7 @@ static struct genl_multicast_group team_change_event_mcgrp = {
24152415
};
24162416

24172417
static int team_nl_send_multicast(struct sk_buff *skb,
2418-
struct team *team, u32 pid)
2418+
struct team *team, u32 portid)
24192419
{
24202420
return genlmsg_multicast_netns(dev_net(team->dev), skb, 0,
24212421
team_change_event_mcgrp.id, GFP_KERNEL);

drivers/net/wireless/mac80211_hwsim.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ MODULE_AUTHOR("Jouni Malinen");
3838
MODULE_DESCRIPTION("Software simulator of 802.11 radio(s) for mac80211");
3939
MODULE_LICENSE("GPL");
4040

41-
static u32 wmediumd_pid;
41+
static u32 wmediumd_portid;
4242

4343
static int radios = 2;
4444
module_param(radios, int, 0444);
@@ -545,7 +545,7 @@ static bool mac80211_hwsim_addr_match(struct mac80211_hwsim_data *data,
545545

546546
static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
547547
struct sk_buff *my_skb,
548-
int dst_pid)
548+
int dst_portid)
549549
{
550550
struct sk_buff *skb;
551551
struct mac80211_hwsim_data *data = hw->priv;
@@ -619,7 +619,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
619619
goto nla_put_failure;
620620

621621
genlmsg_end(skb, msg_head);
622-
genlmsg_unicast(&init_net, skb, dst_pid);
622+
genlmsg_unicast(&init_net, skb, dst_portid);
623623

624624
/* Enqueue the packet */
625625
skb_queue_tail(&data->pending, my_skb);
@@ -715,7 +715,7 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
715715
{
716716
bool ack;
717717
struct ieee80211_tx_info *txi;
718-
u32 _pid;
718+
u32 _portid;
719719

720720
mac80211_hwsim_monitor_rx(hw, skb);
721721

@@ -726,10 +726,10 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
726726
}
727727

728728
/* wmediumd mode check */
729-
_pid = ACCESS_ONCE(wmediumd_pid);
729+
_portid = ACCESS_ONCE(wmediumd_portid);
730730

731-
if (_pid)
732-
return mac80211_hwsim_tx_frame_nl(hw, skb, _pid);
731+
if (_portid)
732+
return mac80211_hwsim_tx_frame_nl(hw, skb, _portid);
733733

734734
/* NO wmediumd detected, perfect medium simulation */
735735
ack = mac80211_hwsim_tx_frame_no_nl(hw, skb);
@@ -814,7 +814,7 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,
814814
struct ieee80211_hw *hw = arg;
815815
struct sk_buff *skb;
816816
struct ieee80211_tx_info *info;
817-
u32 _pid;
817+
u32 _portid;
818818

819819
hwsim_check_magic(vif);
820820

@@ -831,10 +831,10 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,
831831
mac80211_hwsim_monitor_rx(hw, skb);
832832

833833
/* wmediumd mode check */
834-
_pid = ACCESS_ONCE(wmediumd_pid);
834+
_portid = ACCESS_ONCE(wmediumd_portid);
835835

836-
if (_pid)
837-
return mac80211_hwsim_tx_frame_nl(hw, skb, _pid);
836+
if (_portid)
837+
return mac80211_hwsim_tx_frame_nl(hw, skb, _portid);
838838

839839
mac80211_hwsim_tx_frame_no_nl(hw, skb);
840840
dev_kfree_skb(skb);
@@ -1315,7 +1315,7 @@ static void hwsim_send_ps_poll(void *dat, u8 *mac, struct ieee80211_vif *vif)
13151315
struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
13161316
struct sk_buff *skb;
13171317
struct ieee80211_pspoll *pspoll;
1318-
u32 _pid;
1318+
u32 _portid;
13191319

13201320
if (!vp->assoc)
13211321
return;
@@ -1336,10 +1336,10 @@ static void hwsim_send_ps_poll(void *dat, u8 *mac, struct ieee80211_vif *vif)
13361336
memcpy(pspoll->ta, mac, ETH_ALEN);
13371337

13381338
/* wmediumd mode check */
1339-
_pid = ACCESS_ONCE(wmediumd_pid);
1339+
_portid = ACCESS_ONCE(wmediumd_portid);
13401340

1341-
if (_pid)
1342-
return mac80211_hwsim_tx_frame_nl(data->hw, skb, _pid);
1341+
if (_portid)
1342+
return mac80211_hwsim_tx_frame_nl(data->hw, skb, _portid);
13431343

13441344
if (!mac80211_hwsim_tx_frame_no_nl(data->hw, skb))
13451345
printk(KERN_DEBUG "%s: PS-poll frame not ack'ed\n", __func__);
@@ -1353,7 +1353,7 @@ static void hwsim_send_nullfunc(struct mac80211_hwsim_data *data, u8 *mac,
13531353
struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
13541354
struct sk_buff *skb;
13551355
struct ieee80211_hdr *hdr;
1356-
u32 _pid;
1356+
u32 _portid;
13571357

13581358
if (!vp->assoc)
13591359
return;
@@ -1375,10 +1375,10 @@ static void hwsim_send_nullfunc(struct mac80211_hwsim_data *data, u8 *mac,
13751375
memcpy(hdr->addr3, vp->bssid, ETH_ALEN);
13761376

13771377
/* wmediumd mode check */
1378-
_pid = ACCESS_ONCE(wmediumd_pid);
1378+
_portid = ACCESS_ONCE(wmediumd_portid);
13791379

1380-
if (_pid)
1381-
return mac80211_hwsim_tx_frame_nl(data->hw, skb, _pid);
1380+
if (_portid)
1381+
return mac80211_hwsim_tx_frame_nl(data->hw, skb, _portid);
13821382

13831383
if (!mac80211_hwsim_tx_frame_no_nl(data->hw, skb))
13841384
printk(KERN_DEBUG "%s: nullfunc frame not ack'ed\n", __func__);
@@ -1632,10 +1632,10 @@ static int hwsim_register_received_nl(struct sk_buff *skb_2,
16321632
if (info == NULL)
16331633
goto out;
16341634

1635-
wmediumd_pid = info->snd_pid;
1635+
wmediumd_portid = info->snd_portid;
16361636

16371637
printk(KERN_DEBUG "mac80211_hwsim: received a REGISTER, "
1638-
"switching to wmediumd mode with pid %d\n", info->snd_pid);
1638+
"switching to wmediumd mode with pid %d\n", info->snd_portid);
16391639

16401640
return 0;
16411641
out:
@@ -1672,10 +1672,10 @@ static int mac80211_hwsim_netlink_notify(struct notifier_block *nb,
16721672
if (state != NETLINK_URELEASE)
16731673
return NOTIFY_DONE;
16741674

1675-
if (notify->pid == wmediumd_pid) {
1675+
if (notify->portid == wmediumd_portid) {
16761676
printk(KERN_INFO "mac80211_hwsim: wmediumd released netlink"
16771677
" socket, switching to perfect channel medium\n");
1678-
wmediumd_pid = 0;
1678+
wmediumd_portid = 0;
16791679
}
16801680
return NOTIFY_DONE;
16811681

drivers/scsi/scsi_transport_iscsi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,7 +2119,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
21192119
switch (nlh->nlmsg_type) {
21202120
case ISCSI_UEVENT_CREATE_SESSION:
21212121
err = iscsi_if_create_session(priv, ep, ev,
2122-
NETLINK_CB(skb).pid,
2122+
NETLINK_CB(skb).portid,
21232123
ev->u.c_session.initial_cmdsn,
21242124
ev->u.c_session.cmds_max,
21252125
ev->u.c_session.queue_depth);
@@ -2132,7 +2132,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
21322132
}
21332133

21342134
err = iscsi_if_create_session(priv, ep, ev,
2135-
NETLINK_CB(skb).pid,
2135+
NETLINK_CB(skb).portid,
21362136
ev->u.c_bound_session.initial_cmdsn,
21372137
ev->u.c_bound_session.cmds_max,
21382138
ev->u.c_bound_session.queue_depth);

drivers/staging/gdm72xx/netlink_k.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len)
135135
}
136136
memcpy(nlmsg_data(nlh), msg, len);
137137

138-
NETLINK_CB(skb).pid = 0;
138+
NETLINK_CB(skb).portid = 0;
139139
NETLINK_CB(skb).dst_group = 0;
140140

141141
ret = netlink_broadcast(sock, skb, 0, group+1, GFP_ATOMIC);

fs/dlm/netlink.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "dlm_internal.h"
1515

1616
static uint32_t dlm_nl_seqnum;
17-
static uint32_t listener_nlpid;
17+
static uint32_t listener_nlportid;
1818

1919
static struct genl_family family = {
2020
.id = GENL_ID_GENERATE,
@@ -64,13 +64,13 @@ static int send_data(struct sk_buff *skb)
6464
return rv;
6565
}
6666

67-
return genlmsg_unicast(&init_net, skb, listener_nlpid);
67+
return genlmsg_unicast(&init_net, skb, listener_nlportid);
6868
}
6969

7070
static int user_cmd(struct sk_buff *skb, struct genl_info *info)
7171
{
72-
listener_nlpid = info->snd_pid;
73-
printk("user_cmd nlpid %u\n", listener_nlpid);
72+
listener_nlportid = info->snd_portid;
73+
printk("user_cmd nlpid %u\n", listener_nlportid);
7474
return 0;
7575
}
7676

0 commit comments

Comments
 (0)