diff mbox

nl80211: Fix compatibility with older version of libnl

Message ID 1412143285-16862-1-git-send-email-ilan.peer@intel.com
State Accepted
Headers show

Commit Message

Peer, Ilan Oct. 1, 2014, 6:01 a.m. UTC
Commit "nl80211: Remove bridge FDB entry upon sta_remove()" used
nl_sock and nl_socket_* functions which are not compatible with older
versions of libnl. Fix this.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
---
 src/drivers/driver_nl80211.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Jonathan Bither Oct. 1, 2014, 1:18 p.m. UTC | #1
Thanks Ilan,

your patch does indeed fix the issue for me.

On 10/01/2014 02:01 AM, Ilan Peer wrote:
> Commit "nl80211: Remove bridge FDB entry upon sta_remove()" used
> nl_sock and nl_socket_* functions which are not compatible with older
> versions of libnl. Fix this.
>
> Signed-off-by: Ilan Peer <ilan.peer@intel.com>
> ---
>   src/drivers/driver_nl80211.c |    6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
> index 5c922a0..e9e44c0 100644
> --- a/src/drivers/driver_nl80211.c
> +++ b/src/drivers/driver_nl80211.c
> @@ -331,7 +331,7 @@ struct wpa_driver_nl80211_data {
>
>   	int eapol_sock; /* socket for EAPOL frames */
>
> -	struct nl_sock *rtnl_sk; /* nl_sock for NETLINK_ROUTE */
> +	struct nl_handle *rtnl_sk; /* nl_sock for NETLINK_ROUTE */
>
>   	int default_if_indices[16];
>   	int *if_indices;
> @@ -4938,7 +4938,7 @@ static void wpa_driver_nl80211_deinit(struct i802_bss *bss)
>   				   "interface %s from bridge %s: %s",
>   				   bss->ifname, bss->brname, strerror(errno));
>   		if (drv->rtnl_sk)
> -			nl_socket_free(drv->rtnl_sk);
> +			nl80211_handle_destroy(drv->rtnl_sk);
>   	}
>   	if (bss->added_bridge) {
>   		if (linux_br_del(drv->global->ioctl_sock, bss->brname) < 0)
> @@ -10104,7 +10104,7 @@ static void *i802_init(struct hostapd_data *hapd,
>
>   #ifdef CONFIG_LIBNL3_ROUTE
>   	if (bss->added_if_into_bridge) {
> -		drv->rtnl_sk = nl_socket_alloc();
> +		drv->rtnl_sk = nl80211_handle_alloc();
>   		if (drv->rtnl_sk == NULL) {
>   			wpa_printf(MSG_ERROR, "nl80211: Failed to allocate nl_sock");
>   			goto failed;
>
Peer, Ilan Oct. 2, 2014, 6:41 a.m. UTC | #2
Great :)

> -----Original Message-----
> From: hostap-bounces@lists.shmoo.com [mailto:hostap-
> bounces@lists.shmoo.com] On Behalf Of Jonathan Bither
> Sent: Wednesday, October 01, 2014 16:18
> To: hostap@lists.shmoo.com
> Subject: Re: [PATCH] nl80211: Fix compatibility with older version of libnl
> 
> Thanks Ilan,
> 
> your patch does indeed fix the issue for me.
> 
> On 10/01/2014 02:01 AM, Ilan Peer wrote:
> > Commit "nl80211: Remove bridge FDB entry upon sta_remove()" used
> > nl_sock and nl_socket_* functions which are not compatible with older
> > versions of libnl. Fix this.
> >
> > Signed-off-by: Ilan Peer <ilan.peer@intel.com>
> > ---
> >   src/drivers/driver_nl80211.c |    6 +++---
> >   1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/drivers/driver_nl80211.c
> > b/src/drivers/driver_nl80211.c index 5c922a0..e9e44c0 100644
> > --- a/src/drivers/driver_nl80211.c
> > +++ b/src/drivers/driver_nl80211.c
> > @@ -331,7 +331,7 @@ struct wpa_driver_nl80211_data {
> >
> >   	int eapol_sock; /* socket for EAPOL frames */
> >
> > -	struct nl_sock *rtnl_sk; /* nl_sock for NETLINK_ROUTE */
> > +	struct nl_handle *rtnl_sk; /* nl_sock for NETLINK_ROUTE */
> >
> >   	int default_if_indices[16];
> >   	int *if_indices;
> > @@ -4938,7 +4938,7 @@ static void wpa_driver_nl80211_deinit(struct
> i802_bss *bss)
> >   				   "interface %s from bridge %s: %s",
> >   				   bss->ifname, bss->brname,
> strerror(errno));
> >   		if (drv->rtnl_sk)
> > -			nl_socket_free(drv->rtnl_sk);
> > +			nl80211_handle_destroy(drv->rtnl_sk);
> >   	}
> >   	if (bss->added_bridge) {
> >   		if (linux_br_del(drv->global->ioctl_sock, bss->brname) < 0)
> @@
> > -10104,7 +10104,7 @@ static void *i802_init(struct hostapd_data *hapd,
> >
> >   #ifdef CONFIG_LIBNL3_ROUTE
> >   	if (bss->added_if_into_bridge) {
> > -		drv->rtnl_sk = nl_socket_alloc();
> > +		drv->rtnl_sk = nl80211_handle_alloc();
> >   		if (drv->rtnl_sk == NULL) {
> >   			wpa_printf(MSG_ERROR, "nl80211: Failed to allocate
> nl_sock");
> >   			goto failed;
> >
> _______________________________________________
> HostAP mailing list
> HostAP@lists.shmoo.com
> http://lists.shmoo.com/mailman/listinfo/hostap
Jouni Malinen Oct. 3, 2014, 8:31 a.m. UTC | #3
On Wed, Oct 01, 2014 at 08:01:25AM +0200, Ilan Peer wrote:
> Commit "nl80211: Remove bridge FDB entry upon sta_remove()" used
> nl_sock and nl_socket_* functions which are not compatible with older
> versions of libnl. Fix this.

>  #ifdef CONFIG_LIBNL3_ROUTE
>  	if (bss->added_if_into_bridge) {
> -		drv->rtnl_sk = nl_socket_alloc();
> +		drv->rtnl_sk = nl80211_handle_alloc();

That breaks the build. nl80211_handle_alloc() maps to
nl_socket_alloc_cb() which requires struct nl_cb pointer as an argument.
I guess that could use drv->nl_cb or some other existing instance, but
it looks safer to just revert this part since this is within
CONFIG_LIBNL3_ROUTE and nl_socket_alloc() is available.
Jouni Malinen Oct. 3, 2014, 9:26 a.m. UTC | #4
On Wed, Oct 01, 2014 at 08:01:25AM +0200, Ilan Peer wrote:
> Commit "nl80211: Remove bridge FDB entry upon sta_remove()" used
> nl_sock and nl_socket_* functions which are not compatible with older
> versions of libnl. Fix this.

Thanks, applied.

> diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
>  #ifdef CONFIG_LIBNL3_ROUTE
>  	if (bss->added_if_into_bridge) {
> -		drv->rtnl_sk = nl_socket_alloc();
> +		drv->rtnl_sk = nl80211_handle_alloc();

With this part skipped due to build issues. While the end result is
somewhat ugly with rtnl_sk used with nl_socket_alloc() and
nl80211_handle_destroy(), this works and fixes a regression. Additional
cleanup can be done separately if needed.
Peer, Ilan Oct. 5, 2014, 6:16 a.m. UTC | #5
> -----Original Message-----
> From: hostap-bounces@lists.shmoo.com [mailto:hostap-
> bounces@lists.shmoo.com] On Behalf Of Jouni Malinen
> Sent: Friday, October 03, 2014 12:26
> To: hostap@lists.shmoo.com
> Subject: Re: [PATCH] nl80211: Fix compatibility with older version of libnl
> 
> On Wed, Oct 01, 2014 at 08:01:25AM +0200, Ilan Peer wrote:
> > Commit "nl80211: Remove bridge FDB entry upon sta_remove()" used
> > nl_sock and nl_socket_* functions which are not compatible with older
> > versions of libnl. Fix this.
> 
> Thanks, applied.
> 
> > diff --git a/src/drivers/driver_nl80211.c
> > b/src/drivers/driver_nl80211.c  #ifdef CONFIG_LIBNL3_ROUTE
> >  	if (bss->added_if_into_bridge) {
> > -		drv->rtnl_sk = nl_socket_alloc();
> > +		drv->rtnl_sk = nl80211_handle_alloc();
> 
> With this part skipped due to build issues. While the end result is somewhat
> ugly with rtnl_sk used with nl_socket_alloc() and nl80211_handle_destroy(),
> this works and fixes a regression. Additional cleanup can be done separately
> if needed.
> 

Ok. Thanks.

Ilan.
diff mbox

Patch

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 5c922a0..e9e44c0 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -331,7 +331,7 @@  struct wpa_driver_nl80211_data {
 
 	int eapol_sock; /* socket for EAPOL frames */
 
-	struct nl_sock *rtnl_sk; /* nl_sock for NETLINK_ROUTE */
+	struct nl_handle *rtnl_sk; /* nl_sock for NETLINK_ROUTE */
 
 	int default_if_indices[16];
 	int *if_indices;
@@ -4938,7 +4938,7 @@  static void wpa_driver_nl80211_deinit(struct i802_bss *bss)
 				   "interface %s from bridge %s: %s",
 				   bss->ifname, bss->brname, strerror(errno));
 		if (drv->rtnl_sk)
-			nl_socket_free(drv->rtnl_sk);
+			nl80211_handle_destroy(drv->rtnl_sk);
 	}
 	if (bss->added_bridge) {
 		if (linux_br_del(drv->global->ioctl_sock, bss->brname) < 0)
@@ -10104,7 +10104,7 @@  static void *i802_init(struct hostapd_data *hapd,
 
 #ifdef CONFIG_LIBNL3_ROUTE
 	if (bss->added_if_into_bridge) {
-		drv->rtnl_sk = nl_socket_alloc();
+		drv->rtnl_sk = nl80211_handle_alloc();
 		if (drv->rtnl_sk == NULL) {
 			wpa_printf(MSG_ERROR, "nl80211: Failed to allocate nl_sock");
 			goto failed;