[RFC 03/10] nl80211 driver: hold wdev identification for P2P device

Arend van Spriel arend
Mon Feb 11 03:32:13 PST 2013


On 02/11/2013 12:15 PM, Arend van Spriel wrote:
> From: David Spinadel <david.spinadel at intel.com>
> 
> Add wdev_id to i802_bss.
> Init wdev_id to -1 by default.
> Use wdev_id if assigned, instead of ifindex.
> Use wdev_id for events that come from the kernel to identify the
> relevant interface.
> 
> Change-Id: If9f44f688fec1e11c5eda390961199dfd1135a1f
> Signed-hostap: David Spinadel <david.spinadel at intel.com>
> ---
>  src/drivers/driver_nl80211.c |   96 ++++++++++++++++++++++++++++++------------
>  1 file changed, 70 insertions(+), 26 deletions(-)
> 
> diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
> index 75d1f22..670eedc 100644
> --- a/src/drivers/driver_nl80211.c
> +++ b/src/drivers/driver_nl80211.c
> @@ -2345,18 +2357,29 @@ static int process_drv_event(struct nl_msg *msg, void *arg)
>  	struct nlattr *tb[NL80211_ATTR_MAX + 1];
>  	struct i802_bss *bss;
>  	int ifidx = -1;
> +	int64_t wdev_id = -1;
>  
>  	nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
>  		  genlmsg_attrlen(gnlh, 0), NULL);
>  
> -	if (tb[NL80211_ATTR_IFINDEX])
> +	if (tb[NL80211_ATTR_IFINDEX]) {
>  		ifidx = nla_get_u32(tb[NL80211_ATTR_IFINDEX]);
>  
> -	for (bss = &drv->first_bss; bss; bss = bss->next) {
> -		if (ifidx == -1 || ifidx == bss->ifindex) {
> -			do_process_drv_event(bss, gnlh->cmd, tb);
> -			return NL_SKIP;
> -		}
> +		for (bss = &drv->first_bss; bss; bss = bss->next)
> +			if (ifidx == -1 || ifidx == bss->ifindex) {
> +				do_process_drv_event(bss, gnlh->cmd, tb);
> +				return NL_SKIP;
> +			}
> +	} else if (tb[NL80211_ATTR_WDEV]) {
> +		wdev_id = nla_get_u64(tb[NL80211_ATTR_WDEV]);
> +		wpa_printf(MSG_DEBUG, " process event on p2p device");
> +		for (bss = &drv->first_bss; bss; bss = bss->next)
> +			if (wdev_id == bss->wdev_id) {
> +				wpa_printf(MSG_DEBUG,
> +					   "nl80211: Ignored event (cmd=%d) for foreign interface (wdev 0x%llx)",
> +					   gnlh->cmd, wdev_id);

This one causes a warning on 64-bit machines:

../src/drivers/driver_nl80211.c: In function ?process_drv_event?:
../src/drivers/driver_nl80211.c:2381:9: warning: format ?%llx? expects
argument of type ?long long unsigned int?, but argument 4 has type
?int64_t? [-Wformat]

> +				return NL_SKIP;
> +			}
>  	}
>  
>  	wpa_printf(MSG_DEBUG, "nl80211: Ignored event (cmd=%d) for foreign "
> @@ -3648,13 +3678,18 @@ nl80211_scan_common(struct wpa_driver_nl80211_data *drv, u8 cmd,
>  
>  	nl80211_cmd(drv, msg, 0, cmd);
>  
> -	if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) < 0)
> -		goto fail;
> +	if (wdev_id == -1) {
> +		err = nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) < 0;
> +		if (err)
> +			goto nla_put_failure;
> +	} else {
> +		NLA_PUT_U64(msg, NL80211_ATTR_WDEV, wdev_id);
> +	}

Seems like you could use nl80211_set_iface_id() here as well. Maybe I am
overlooking something.

>  
>  	if (params->num_ssids) {
>  		struct nl_msg *ssids = nlmsg_alloc();
>  		if (ssids == NULL)
> -			goto fail;
> +			goto nla_put_failure;
>  		for (i = 0; i < params->num_ssids; i++) {
>  			wpa_hexdump_ascii(MSG_MSGDUMP, "nl80211: Scan SSID",
>  					  params->ssids[i].ssid,





More information about the Hostap mailing list