All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iw: add libnl-tiny support
@ 2016-02-23 18:43 Dima Krasner
  2016-03-02 13:59 ` Johannes Berg
  2016-03-05 15:11 ` [PATCH] iw: add libnl-tiny support, reimplemented Dima Krasner
  0 siblings, 2 replies; 7+ messages in thread
From: Dima Krasner @ 2016-02-23 18:43 UTC (permalink / raw)
  To: linux-wireless

This allows small static builds, especially when using musl libc.

Signed-off-by: Dima Krasner <dima@dimakrasner.com>
---
 Makefile |  8 ++++++++
 iw.c     | 10 ++++++++--
 iw.h     |  2 +-
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index e61825e..4077020 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,8 @@ OBJS += $(OBJS-y) $(OBJS-Y)
 ALL = iw
 
 ifeq ($(NO_PKG_CONFIG),)
+NLTINYFOUND := $(shell $(PKG_CONFIG) libnl-tiny && echo Y)
+ifneq ($(NLTINYFOUND),Y)
 NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y)
 ifneq ($(NL3xFOUND),Y)
 NL31FOUND := $(shell $(PKG_CONFIG) --exact-version=3.1 libnl-3.1 && echo Y)
@@ -40,6 +42,12 @@ endif
 endif
 endif
 endif
+endif
+
+ifeq ($(NLTINYFOUND),Y)
+CFLAGS += -DCONFIG_LIBNL_TINY
+NLLIBNAME = libnl-tiny
+endif
 
 ifeq ($(NL1FOUND),Y)
 NLLIBNAME = libnl-1
diff --git a/iw.c b/iw.c
index 0f511d9..f702e92 100644
--- a/iw.c
+++ b/iw.c
@@ -23,8 +23,14 @@
 #include "nl80211.h"
 #include "iw.h"
 
+#ifdef CONFIG_LIBNL_TINY
+#define nl_handle nl_sock
+#define nl_handle_alloc_cb nl_socket_alloc_cb
+#define nl_handle_destroy nl_socket_free
+#endif
+
 /* libnl 1.x compatibility code */
-#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
+#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30) && !defined(CONFIG_LIBNL_TINY)
 static inline struct nl_handle *nl_socket_alloc(void)
 {
 	return nl_handle_alloc();
@@ -40,7 +46,7 @@ static inline int nl_socket_set_buffer_size(struct nl_sock *sk,
 {
 	return nl_set_buffer_size(sk, rxbuf, txbuf);
 }
-#endif /* CONFIG_LIBNL20 && CONFIG_LIBNL30 */
+#endif /* CONFIG_LIBNL20 && CONFIG_LIBNL30 && CONFIG_LIBNL_TINY */
 
 int iw_debug = 0;
 
diff --git a/iw.h b/iw.h
index d91a33e..dcac930 100644
--- a/iw.h
+++ b/iw.h
@@ -14,7 +14,7 @@
 #define ETH_ALEN 6
 
 /* libnl 1.x compatibility code */
-#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
+#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30) && !defined(CONFIG_LIBNL_TINY)
 #  define nl_sock nl_handle
 #endif
 
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] iw: add libnl-tiny support
  2016-02-23 18:43 [PATCH] iw: add libnl-tiny support Dima Krasner
@ 2016-03-02 13:59 ` Johannes Berg
  2016-03-05 15:51   ` Dima Krasner
  2016-03-05 15:11 ` [PATCH] iw: add libnl-tiny support, reimplemented Dima Krasner
  1 sibling, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2016-03-02 13:59 UTC (permalink / raw)
  To: Dima Krasner, linux-wireless

On Tue, 2016-02-23 at 20:43 +0200, Dima Krasner wrote:
> 
> +#ifdef CONFIG_LIBNL_TINY
> +#define nl_handle nl_sock
[...]
>  /* libnl 1.x compatibility code */
> -#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
> +#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30) &&
> !defined(CONFIG_LIBNL_TINY)
>  #  define nl_sock nl_handle
>  #endif


This makes no sense. Clearly, nl_sock was intended to be the struct
name used in the code, and it seems that nl-tiny implements the libnl
1.1 API, so you should work with that code instead of redefining
everything.

johannes

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] iw: add libnl-tiny support, reimplemented
  2016-02-23 18:43 [PATCH] iw: add libnl-tiny support Dima Krasner
  2016-03-02 13:59 ` Johannes Berg
@ 2016-03-05 15:11 ` Dima Krasner
  2016-03-06 12:39   ` Kalle Valo
  1 sibling, 1 reply; 7+ messages in thread
From: Dima Krasner @ 2016-03-05 15:11 UTC (permalink / raw)
  To: linux-wireless; +Cc: Dima Krasner

This allows small static builds, especially when using musl libc.

Signed-off-by: Dima Krasner <dima@dimakrasner.com>
---
 Makefile | 8 ++++++++
 iw.c     | 4 ++--
 iw.h     | 2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index e61825e..4077020 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,8 @@ OBJS += $(OBJS-y) $(OBJS-Y)
 ALL = iw
 
 ifeq ($(NO_PKG_CONFIG),)
+NLTINYFOUND := $(shell $(PKG_CONFIG) libnl-tiny && echo Y)
+ifneq ($(NLTINYFOUND),Y)
 NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y)
 ifneq ($(NL3xFOUND),Y)
 NL31FOUND := $(shell $(PKG_CONFIG) --exact-version=3.1 libnl-3.1 && echo Y)
@@ -40,6 +42,12 @@ endif
 endif
 endif
 endif
+endif
+
+ifeq ($(NLTINYFOUND),Y)
+CFLAGS += -DCONFIG_LIBNL_TINY
+NLLIBNAME = libnl-tiny
+endif
 
 ifeq ($(NL1FOUND),Y)
 NLLIBNAME = libnl-1
diff --git a/iw.c b/iw.c
index 0f511d9..c52d7ba 100644
--- a/iw.c
+++ b/iw.c
@@ -24,7 +24,7 @@
 #include "iw.h"
 
 /* libnl 1.x compatibility code */
-#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
+#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30) && !defined(CONFIG_LIBNL_TINY)
 static inline struct nl_handle *nl_socket_alloc(void)
 {
 	return nl_handle_alloc();
@@ -40,7 +40,7 @@ static inline int nl_socket_set_buffer_size(struct nl_sock *sk,
 {
 	return nl_set_buffer_size(sk, rxbuf, txbuf);
 }
-#endif /* CONFIG_LIBNL20 && CONFIG_LIBNL30 */
+#endif /* CONFIG_LIBNL20 && CONFIG_LIBNL30 && CONFIG_LIBNL_TINY */
 
 int iw_debug = 0;
 
diff --git a/iw.h b/iw.h
index d91a33e..37757d4 100644
--- a/iw.h
+++ b/iw.h
@@ -13,7 +13,7 @@
 
 #define ETH_ALEN 6
 
-/* libnl 1.x compatibility code */
+/* libnl 1.x and libnl-tiny compatibility code */
 #if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
 #  define nl_sock nl_handle
 #endif
-- 
2.1.4

-- 
Dima Krasner <dima@dimakrasner.com>


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] iw: add libnl-tiny support
  2016-03-02 13:59 ` Johannes Berg
@ 2016-03-05 15:51   ` Dima Krasner
  2016-03-08 17:00     ` Johannes Berg
  0 siblings, 1 reply; 7+ messages in thread
From: Dima Krasner @ 2016-03-05 15:51 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

On Wed, 02 Mar 2016 14:59:36 +0100
Johannes Berg <johannes@sipsolutions.net> wrote:

> you should work with that code instead of redefining
> everything.

Done.

(I sent this patch in a new thread earlier, because I couldn't find your reply in my inbox. Sorry for that.)

Signed-off-by: Dima Krasner <dima@dimakrasner.com>
---
 Makefile | 8 ++++++++
 iw.c     | 4 ++--
 iw.h     | 2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index e61825e..4077020 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,8 @@ OBJS += $(OBJS-y) $(OBJS-Y)
 ALL = iw
 
 ifeq ($(NO_PKG_CONFIG),)
+NLTINYFOUND := $(shell $(PKG_CONFIG) libnl-tiny && echo Y)
+ifneq ($(NLTINYFOUND),Y)
 NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y)
 ifneq ($(NL3xFOUND),Y)
 NL31FOUND := $(shell $(PKG_CONFIG) --exact-version=3.1 libnl-3.1 && echo Y)
@@ -40,6 +42,12 @@ endif
 endif
 endif
 endif
+endif
+
+ifeq ($(NLTINYFOUND),Y)
+CFLAGS += -DCONFIG_LIBNL_TINY
+NLLIBNAME = libnl-tiny
+endif
 
 ifeq ($(NL1FOUND),Y)
 NLLIBNAME = libnl-1
diff --git a/iw.c b/iw.c
index 0f511d9..c52d7ba 100644
--- a/iw.c
+++ b/iw.c
@@ -24,7 +24,7 @@
 #include "iw.h"
 
 /* libnl 1.x compatibility code */
-#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
+#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30) && !defined(CONFIG_LIBNL_TINY)
 static inline struct nl_handle *nl_socket_alloc(void)
 {
 	return nl_handle_alloc();
@@ -40,7 +40,7 @@ static inline int nl_socket_set_buffer_size(struct nl_sock *sk,
 {
 	return nl_set_buffer_size(sk, rxbuf, txbuf);
 }
-#endif /* CONFIG_LIBNL20 && CONFIG_LIBNL30 */
+#endif /* CONFIG_LIBNL20 && CONFIG_LIBNL30 && CONFIG_LIBNL_TINY */
 
 int iw_debug = 0;
 
diff --git a/iw.h b/iw.h
index d91a33e..37757d4 100644
--- a/iw.h
+++ b/iw.h
@@ -13,7 +13,7 @@
 
 #define ETH_ALEN 6
 
-/* libnl 1.x compatibility code */
+/* libnl 1.x and libnl-tiny compatibility code */
 #if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
 #  define nl_sock nl_handle
 #endif
-- 
2.1.4

-- 
Dima Krasner <dima@dimakrasner.com>


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] iw: add libnl-tiny support, reimplemented
  2016-03-05 15:11 ` [PATCH] iw: add libnl-tiny support, reimplemented Dima Krasner
@ 2016-03-06 12:39   ` Kalle Valo
  0 siblings, 0 replies; 7+ messages in thread
From: Kalle Valo @ 2016-03-06 12:39 UTC (permalink / raw)
  To: Dima Krasner; +Cc: linux-wireless

Dima Krasner <dima@dimakrasner.com> writes:

> This allows small static builds, especially when using musl libc.
>
> Signed-off-by: Dima Krasner <dima@dimakrasner.com>

When sending a new version of the patch the standard practise is to add
v2 to the subject, like this:

Subject: [PATCH v2] iw: add libnl-tiny support

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] iw: add libnl-tiny support
  2016-03-05 15:51   ` Dima Krasner
@ 2016-03-08 17:00     ` Johannes Berg
  0 siblings, 0 replies; 7+ messages in thread
From: Johannes Berg @ 2016-03-08 17:00 UTC (permalink / raw)
  To: Dima Krasner; +Cc: linux-wireless

This:

> -#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
> +#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30) && !defined(CONFIG_LIBNL_TINY)

> -#endif /* CONFIG_LIBNL20 && CONFIG_LIBNL30 */
> +#endif /* CONFIG_LIBNL20 && CONFIG_LIBNL30 && CONFIG_LIBNL_TINY */

can be handled by just defining CONFIG_LIBNL20 for libnl-tiny.

> -/* libnl 1.x compatibility code */
> +/* libnl 1.x and libnl-tiny compatibility code */
>  #if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
>  #  define nl_sock nl_handle
>  #endif

Are you sure this is needed? Elsewhere you said libnl-tiny uses libnl20
compatible API, which is with nl_handle. If this is needed perhaps some
code erroneously uses nl_sock instead of nl_handle?

Perhaps we should also consider treating 2.0/3.x as the default API and
use nl_handle instead of nl_sock in the code.

johannes


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] iw: Add libnl-tiny support
@ 2015-11-03 22:14 Dima Krasner
  0 siblings, 0 replies; 7+ messages in thread
From: Dima Krasner @ 2015-11-03 22:14 UTC (permalink / raw)
  To: linux-wireless

[-- Attachment #1: Type: text/plain, Size: 2364 bytes --]

Hi,

I'd like to upstream this patch, which adds libnl-tiny support to iw, as a smaller alternative to libnl 2.0. It's great for static builds against musl.

Cheers,
Dima 

>From 88ad01745f6f8b2d5fcc066d18dba9dce21609fd Mon Sep 17 00:00:00 2001
From: Dima Krasner <dima@dimakrasner.com>
Date: Wed, 4 Nov 2015 00:04:44 +0200
Subject: [PATCH] Added libnl-tiny support

---
 Makefile |  8 ++++++++
 iw.c     | 10 ++++++++--
 iw.h     |  2 +-
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index e61825e..63169a3 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,8 @@ OBJS += $(OBJS-y) $(OBJS-Y)
 ALL = iw
 
 ifeq ($(NO_PKG_CONFIG),)
+NLTINYFOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-tiny && echo Y)
+ifneq ($(NLTINYFOUND),Y)
 NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y)
 ifneq ($(NL3xFOUND),Y)
 NL31FOUND := $(shell $(PKG_CONFIG) --exact-version=3.1 libnl-3.1 && echo Y)
@@ -40,6 +42,12 @@ endif
 endif
 endif
 endif
+endif
+
+ifeq ($(NLTINYFOUND),Y)
+CFLAGS += -DCONFIG_LIBNL_TINY
+NLLIBNAME = libnl-tiny
+endif
 
 ifeq ($(NL1FOUND),Y)
 NLLIBNAME = libnl-1
diff --git a/iw.c b/iw.c
index 0f511d9..f702e92 100644
--- a/iw.c
+++ b/iw.c
@@ -23,8 +23,14 @@
 #include "nl80211.h"
 #include "iw.h"
 
+#ifdef CONFIG_LIBNL_TINY
+#define nl_handle nl_sock
+#define nl_handle_alloc_cb nl_socket_alloc_cb
+#define nl_handle_destroy nl_socket_free
+#endif
+
 /* libnl 1.x compatibility code */
-#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
+#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30) && !defined(CONFIG_LIBNL_TINY)
 static inline struct nl_handle *nl_socket_alloc(void)
 {
 	return nl_handle_alloc();
@@ -40,7 +46,7 @@ static inline int nl_socket_set_buffer_size(struct nl_sock *sk,
 {
 	return nl_set_buffer_size(sk, rxbuf, txbuf);
 }
-#endif /* CONFIG_LIBNL20 && CONFIG_LIBNL30 */
+#endif /* CONFIG_LIBNL20 && CONFIG_LIBNL30 && CONFIG_LIBNL_TINY */
 
 int iw_debug = 0;
 
diff --git a/iw.h b/iw.h
index 263e8b1..93813be 100644
--- a/iw.h
+++ b/iw.h
@@ -14,7 +14,7 @@
 #define ETH_ALEN 6
 
 /* libnl 1.x compatibility code */
-#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
+#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30) && !defined(CONFIG_LIBNL_TINY)
 #  define nl_sock nl_handle
 #endif
 
-- 
1.9.1



-- 
Dima Krasner <dima@dimakrasner.com>

[-- Attachment #2: 0001-Added-libnl-tiny-support.patch --]
[-- Type: text/x-diff, Size: 2149 bytes --]

>From 88ad01745f6f8b2d5fcc066d18dba9dce21609fd Mon Sep 17 00:00:00 2001
From: Dima Krasner <dima@dimakrasner.com>
Date: Wed, 4 Nov 2015 00:04:44 +0200
Subject: [PATCH] Added libnl-tiny support

---
 Makefile |  8 ++++++++
 iw.c     | 10 ++++++++--
 iw.h     |  2 +-
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index e61825e..63169a3 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,8 @@ OBJS += $(OBJS-y) $(OBJS-Y)
 ALL = iw
 
 ifeq ($(NO_PKG_CONFIG),)
+NLTINYFOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-tiny && echo Y)
+ifneq ($(NLTINYFOUND),Y)
 NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y)
 ifneq ($(NL3xFOUND),Y)
 NL31FOUND := $(shell $(PKG_CONFIG) --exact-version=3.1 libnl-3.1 && echo Y)
@@ -40,6 +42,12 @@ endif
 endif
 endif
 endif
+endif
+
+ifeq ($(NLTINYFOUND),Y)
+CFLAGS += -DCONFIG_LIBNL_TINY
+NLLIBNAME = libnl-tiny
+endif
 
 ifeq ($(NL1FOUND),Y)
 NLLIBNAME = libnl-1
diff --git a/iw.c b/iw.c
index 0f511d9..f702e92 100644
--- a/iw.c
+++ b/iw.c
@@ -23,8 +23,14 @@
 #include "nl80211.h"
 #include "iw.h"
 
+#ifdef CONFIG_LIBNL_TINY
+#define nl_handle nl_sock
+#define nl_handle_alloc_cb nl_socket_alloc_cb
+#define nl_handle_destroy nl_socket_free
+#endif
+
 /* libnl 1.x compatibility code */
-#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
+#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30) && !defined(CONFIG_LIBNL_TINY)
 static inline struct nl_handle *nl_socket_alloc(void)
 {
 	return nl_handle_alloc();
@@ -40,7 +46,7 @@ static inline int nl_socket_set_buffer_size(struct nl_sock *sk,
 {
 	return nl_set_buffer_size(sk, rxbuf, txbuf);
 }
-#endif /* CONFIG_LIBNL20 && CONFIG_LIBNL30 */
+#endif /* CONFIG_LIBNL20 && CONFIG_LIBNL30 && CONFIG_LIBNL_TINY */
 
 int iw_debug = 0;
 
diff --git a/iw.h b/iw.h
index 263e8b1..93813be 100644
--- a/iw.h
+++ b/iw.h
@@ -14,7 +14,7 @@
 #define ETH_ALEN 6
 
 /* libnl 1.x compatibility code */
-#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
+#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30) && !defined(CONFIG_LIBNL_TINY)
 #  define nl_sock nl_handle
 #endif
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-03-08 17:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-23 18:43 [PATCH] iw: add libnl-tiny support Dima Krasner
2016-03-02 13:59 ` Johannes Berg
2016-03-05 15:51   ` Dima Krasner
2016-03-08 17:00     ` Johannes Berg
2016-03-05 15:11 ` [PATCH] iw: add libnl-tiny support, reimplemented Dima Krasner
2016-03-06 12:39   ` Kalle Valo
  -- strict thread matches above, loose matches on Subject: below --
2015-11-03 22:14 [PATCH] iw: Add libnl-tiny support Dima Krasner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.