Skip to content

Commit

Permalink
netlink: Rename pid to portid to avoid confusion
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ebiederm authored and davem330 committed Sep 10, 2012
1 parent 9f00d97 commit 15e4730
Show file tree
Hide file tree
Showing 75 changed files with 728 additions and 728 deletions.
4 changes: 2 additions & 2 deletions crypto/crypto_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static int crypto_report_alg(struct crypto_alg *alg,
struct crypto_user_alg *ualg;
int err = 0;

nlh = nlmsg_put(skb, NETLINK_CB(in_skb).pid, info->nlmsg_seq,
nlh = nlmsg_put(skb, NETLINK_CB(in_skb).portid, info->nlmsg_seq,
CRYPTO_MSG_GETALG, sizeof(*ualg), info->nlmsg_flags);
if (!nlh) {
err = -EMSGSIZE;
Expand Down Expand Up @@ -216,7 +216,7 @@ static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
if (err)
return err;

return nlmsg_unicast(crypto_nlsk, skb, NETLINK_CB(in_skb).pid);
return nlmsg_unicast(crypto_nlsk, skb, NETLINK_CB(in_skb).portid);
}

static int crypto_dump_report(struct sk_buff *skb, struct netlink_callback *cb)
Expand Down
38 changes: 19 additions & 19 deletions drivers/net/team/team.c
Original file line number Diff line number Diff line change
Expand Up @@ -1886,7 +1886,7 @@ static int team_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info)
if (!msg)
return -ENOMEM;

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

genlmsg_end(msg, hdr);

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

err_msg_put:
nlmsg_free(msg);
Expand Down Expand Up @@ -1952,7 +1952,7 @@ static int team_nl_send_generic(struct genl_info *info, struct team *team,
if (err < 0)
goto err_fill;

err = genlmsg_unicast(genl_info_net(info), skb, info->snd_pid);
err = genlmsg_unicast(genl_info_net(info), skb, info->snd_portid);
return err;

err_fill:
Expand All @@ -1961,11 +1961,11 @@ static int team_nl_send_generic(struct genl_info *info, struct team *team,
}

typedef int team_nl_send_func_t(struct sk_buff *skb,
struct team *team, u32 pid);
struct team *team, u32 portid);

static int team_nl_send_unicast(struct sk_buff *skb, struct team *team, u32 pid)
static int team_nl_send_unicast(struct sk_buff *skb, struct team *team, u32 portid)
{
return genlmsg_unicast(dev_net(team->dev), skb, pid);
return genlmsg_unicast(dev_net(team->dev), skb, portid);
}

static int team_nl_fill_one_option_get(struct sk_buff *skb, struct team *team,
Expand Down Expand Up @@ -2050,13 +2050,13 @@ static int team_nl_fill_one_option_get(struct sk_buff *skb, struct team *team,
}

static int __send_and_alloc_skb(struct sk_buff **pskb,
struct team *team, u32 pid,
struct team *team, u32 portid,
team_nl_send_func_t *send_func)
{
int err;

if (*pskb) {
err = send_func(*pskb, team, pid);
err = send_func(*pskb, team, portid);
if (err)
return err;
}
Expand All @@ -2066,7 +2066,7 @@ static int __send_and_alloc_skb(struct sk_buff **pskb,
return 0;
}

static int team_nl_send_options_get(struct team *team, u32 pid, u32 seq,
static int team_nl_send_options_get(struct team *team, u32 portid, u32 seq,
int flags, team_nl_send_func_t *send_func,
struct list_head *sel_opt_inst_list)
{
Expand All @@ -2083,11 +2083,11 @@ static int team_nl_send_options_get(struct team *team, u32 pid, u32 seq,
struct team_option_inst, tmp_list);

start_again:
err = __send_and_alloc_skb(&skb, team, pid, send_func);
err = __send_and_alloc_skb(&skb, team, portid, send_func);
if (err)
return err;

hdr = genlmsg_put(skb, pid, seq, &team_nl_family, flags | NLM_F_MULTI,
hdr = genlmsg_put(skb, portid, seq, &team_nl_family, flags | NLM_F_MULTI,
TEAM_CMD_OPTIONS_GET);
if (IS_ERR(hdr))
return PTR_ERR(hdr);
Expand Down Expand Up @@ -2120,15 +2120,15 @@ static int team_nl_send_options_get(struct team *team, u32 pid, u32 seq,
goto start_again;

send_done:
nlh = nlmsg_put(skb, pid, seq, NLMSG_DONE, 0, flags | NLM_F_MULTI);
nlh = nlmsg_put(skb, portid, seq, NLMSG_DONE, 0, flags | NLM_F_MULTI);
if (!nlh) {
err = __send_and_alloc_skb(&skb, team, pid, send_func);
err = __send_and_alloc_skb(&skb, team, portid, send_func);
if (err)
goto errout;
goto send_done;
}

return send_func(skb, team, pid);
return send_func(skb, team, portid);

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

list_for_each_entry(opt_inst, &team->option_inst_list, list)
list_add_tail(&opt_inst->tmp_list, &sel_opt_inst_list);
err = team_nl_send_options_get(team, info->snd_pid, info->snd_seq,
err = team_nl_send_options_get(team, info->snd_portid, info->snd_seq,
NLM_F_ACK, team_nl_send_unicast,
&sel_opt_inst_list);

Expand Down Expand Up @@ -2305,15 +2305,15 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
}

static int team_nl_fill_port_list_get(struct sk_buff *skb,
u32 pid, u32 seq, int flags,
u32 portid, u32 seq, int flags,
struct team *team,
bool fillall)
{
struct nlattr *port_list;
void *hdr;
struct team_port *port;

hdr = genlmsg_put(skb, pid, seq, &team_nl_family, flags,
hdr = genlmsg_put(skb, portid, seq, &team_nl_family, flags,
TEAM_CMD_PORT_LIST_GET);
if (IS_ERR(hdr))
return PTR_ERR(hdr);
Expand Down Expand Up @@ -2362,7 +2362,7 @@ static int team_nl_fill_port_list_get_all(struct sk_buff *skb,
struct genl_info *info, int flags,
struct team *team)
{
return team_nl_fill_port_list_get(skb, info->snd_pid,
return team_nl_fill_port_list_get(skb, info->snd_portid,
info->snd_seq, NLM_F_ACK,
team, true);
}
Expand Down Expand Up @@ -2415,7 +2415,7 @@ static struct genl_multicast_group team_change_event_mcgrp = {
};

static int team_nl_send_multicast(struct sk_buff *skb,
struct team *team, u32 pid)
struct team *team, u32 portid)
{
return genlmsg_multicast_netns(dev_net(team->dev), skb, 0,
team_change_event_mcgrp.id, GFP_KERNEL);
Expand Down
46 changes: 23 additions & 23 deletions drivers/net/wireless/mac80211_hwsim.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ MODULE_AUTHOR("Jouni Malinen");
MODULE_DESCRIPTION("Software simulator of 802.11 radio(s) for mac80211");
MODULE_LICENSE("GPL");

static u32 wmediumd_pid;
static u32 wmediumd_portid;

static int radios = 2;
module_param(radios, int, 0444);
Expand Down Expand Up @@ -545,7 +545,7 @@ static bool mac80211_hwsim_addr_match(struct mac80211_hwsim_data *data,

static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
struct sk_buff *my_skb,
int dst_pid)
int dst_portid)
{
struct sk_buff *skb;
struct mac80211_hwsim_data *data = hw->priv;
Expand Down Expand Up @@ -619,7 +619,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
goto nla_put_failure;

genlmsg_end(skb, msg_head);
genlmsg_unicast(&init_net, skb, dst_pid);
genlmsg_unicast(&init_net, skb, dst_portid);

/* Enqueue the packet */
skb_queue_tail(&data->pending, my_skb);
Expand Down Expand Up @@ -715,7 +715,7 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
{
bool ack;
struct ieee80211_tx_info *txi;
u32 _pid;
u32 _portid;

mac80211_hwsim_monitor_rx(hw, skb);

Expand All @@ -726,10 +726,10 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
}

/* wmediumd mode check */
_pid = ACCESS_ONCE(wmediumd_pid);
_portid = ACCESS_ONCE(wmediumd_portid);

if (_pid)
return mac80211_hwsim_tx_frame_nl(hw, skb, _pid);
if (_portid)
return mac80211_hwsim_tx_frame_nl(hw, skb, _portid);

/* NO wmediumd detected, perfect medium simulation */
ack = mac80211_hwsim_tx_frame_no_nl(hw, skb);
Expand Down Expand Up @@ -814,7 +814,7 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,
struct ieee80211_hw *hw = arg;
struct sk_buff *skb;
struct ieee80211_tx_info *info;
u32 _pid;
u32 _portid;

hwsim_check_magic(vif);

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

/* wmediumd mode check */
_pid = ACCESS_ONCE(wmediumd_pid);
_portid = ACCESS_ONCE(wmediumd_portid);

if (_pid)
return mac80211_hwsim_tx_frame_nl(hw, skb, _pid);
if (_portid)
return mac80211_hwsim_tx_frame_nl(hw, skb, _portid);

mac80211_hwsim_tx_frame_no_nl(hw, skb);
dev_kfree_skb(skb);
Expand Down Expand Up @@ -1315,7 +1315,7 @@ static void hwsim_send_ps_poll(void *dat, u8 *mac, struct ieee80211_vif *vif)
struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
struct sk_buff *skb;
struct ieee80211_pspoll *pspoll;
u32 _pid;
u32 _portid;

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

/* wmediumd mode check */
_pid = ACCESS_ONCE(wmediumd_pid);
_portid = ACCESS_ONCE(wmediumd_portid);

if (_pid)
return mac80211_hwsim_tx_frame_nl(data->hw, skb, _pid);
if (_portid)
return mac80211_hwsim_tx_frame_nl(data->hw, skb, _portid);

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

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

/* wmediumd mode check */
_pid = ACCESS_ONCE(wmediumd_pid);
_portid = ACCESS_ONCE(wmediumd_portid);

if (_pid)
return mac80211_hwsim_tx_frame_nl(data->hw, skb, _pid);
if (_portid)
return mac80211_hwsim_tx_frame_nl(data->hw, skb, _portid);

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

wmediumd_pid = info->snd_pid;
wmediumd_portid = info->snd_portid;

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

return 0;
out:
Expand Down Expand Up @@ -1672,10 +1672,10 @@ static int mac80211_hwsim_netlink_notify(struct notifier_block *nb,
if (state != NETLINK_URELEASE)
return NOTIFY_DONE;

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

Expand Down
4 changes: 2 additions & 2 deletions drivers/scsi/scsi_transport_iscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2119,7 +2119,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
switch (nlh->nlmsg_type) {
case ISCSI_UEVENT_CREATE_SESSION:
err = iscsi_if_create_session(priv, ep, ev,
NETLINK_CB(skb).pid,
NETLINK_CB(skb).portid,
ev->u.c_session.initial_cmdsn,
ev->u.c_session.cmds_max,
ev->u.c_session.queue_depth);
Expand All @@ -2132,7 +2132,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
}

err = iscsi_if_create_session(priv, ep, ev,
NETLINK_CB(skb).pid,
NETLINK_CB(skb).portid,
ev->u.c_bound_session.initial_cmdsn,
ev->u.c_bound_session.cmds_max,
ev->u.c_bound_session.queue_depth);
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/gdm72xx/netlink_k.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len)
}
memcpy(nlmsg_data(nlh), msg, len);

NETLINK_CB(skb).pid = 0;
NETLINK_CB(skb).portid = 0;
NETLINK_CB(skb).dst_group = 0;

ret = netlink_broadcast(sock, skb, 0, group+1, GFP_ATOMIC);
Expand Down
8 changes: 4 additions & 4 deletions fs/dlm/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "dlm_internal.h"

static uint32_t dlm_nl_seqnum;
static uint32_t listener_nlpid;
static uint32_t listener_nlportid;

static struct genl_family family = {
.id = GENL_ID_GENERATE,
Expand Down Expand Up @@ -64,13 +64,13 @@ static int send_data(struct sk_buff *skb)
return rv;
}

return genlmsg_unicast(&init_net, skb, listener_nlpid);
return genlmsg_unicast(&init_net, skb, listener_nlportid);
}

static int user_cmd(struct sk_buff *skb, struct genl_info *info)
{
listener_nlpid = info->snd_pid;
printk("user_cmd nlpid %u\n", listener_nlpid);
listener_nlportid = info->snd_portid;
printk("user_cmd nlpid %u\n", listener_nlportid);
return 0;
}

Expand Down
Loading

0 comments on commit 15e4730

Please sign in to comment.