Skip to contentSkip to conversation

tools: ynl: user space C

PATCH Superseded Jakub Kicinski 3 participants 10 messages Jun 4, 2023 – Jun 5, 2023

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

v2 cover tools: ynl: user space C

Use the code gen which is already in tree to generate a user space library for a handful of simple families. I find YNL C quite useful in some WIP projects, and I think others may find it useful, too. I was hoping someone will pick this work up and finish it... but it seems that Python YNL has largely stolen the thunder. Python may not be great for selftest, tho, and actually this lib is more fully-featured. The Python script was meant as a quick demo, funny how those things go.

v2:
- fix kdoc on patch 2
v1: https://lore.kernel.org/all/[email protected]/

Jakub Kicinski (4):
tools: ynl-gen: clean up stray new lines at the end of reply-less
requests
tools: ynl: user space helpers
tools: ynl: support fou and netdev in C
tools: ynl: add sample for netdev

 .../userspace-api/netlink/intro-specs.rst     |  79 ++
 tools/net/ynl/Makefile                        |  19 +
 tools/net/ynl/generated/Makefile              |  45 +
 tools/net/ynl/generated/fou-user.c            | 340 +++++++
 tools/net/ynl/generated/fou-user.h            | 337 +++++++
 tools/net/ynl/generated/netdev-user.c         | 250 +++++
 tools/net/ynl/generated/netdev-user.h         |  88 ++
 tools/net/ynl/lib/Makefile                    |  28 +
 tools/net/ynl/lib/ynl.c                       | 901 ++++++++++++++++++
 tools/net/ynl/lib/ynl.h                       | 237 +++++
 tools/net/ynl/samples/.gitignore              |   1 +
 tools/net/ynl/samples/Makefile                |  28 +
 tools/net/ynl/samples/netdev.c                | 108 +++
 tools/net/ynl/ynl-gen-c.py                    |   7 +-
 tools/net/ynl/ynl-regen.sh                    |   2 +-
 15 files changed, 2466 insertions(+), 4 deletions(-)
 create mode 100644 tools/net/ynl/Makefile
 create mode 100644 tools/net/ynl/generated/Makefile
 create mode 100644 tools/net/ynl/generated/fou-user.c
 create mode 100644 tools/net/ynl/generated/fou-user.h
 create mode 100644 tools/net/ynl/generated/netdev-user.c
 create mode 100644 tools/net/ynl/generated/netdev-user.h
 create mode 100644 tools/net/ynl/lib/Makefile
 create mode 100644 tools/net/ynl/lib/ynl.c
 create mode 100644 tools/net/ynl/lib/ynl.h
 create mode 100644 tools/net/ynl/samples/.gitignore
 create mode 100644 tools/net/ynl/samples/Makefile
 create mode 100644 tools/net/ynl/samples/netdev.c
Signature · 1 line
2.40.1
author maintainer
#1 lore raw

PATCH v2 1/4 tools: ynl-gen: clean up stray new lines at the end of reply-less requests

Do not print empty lines before closing brackets.

---
 tools/net/ynl/ynl-gen-c.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
tools/net/ynl/ynl-gen-c.py +4 -3
index 4c12c6f8968e..1e64c5c2a087 100755
@@ -944,9 +944,10 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
     def _is_cond(cls, line):
         return line.startswith('if') or line.startswith('while') or line.startswith('for')
 
-    def p(self, line, add_ind=0):
+    def p(self, line, add_ind=0, eat_nl=False):
         if self._nl:
-            self._out.write('\n')
+            if not eat_nl:
+                self._out.write('\n')
             self._nl = False
         ind = self._ind
         if line[-1] == ':':
@@ -971,7 +972,7 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
         if line and line[0] not in {';', ','}:
             line = ' ' + line
         self._ind -= 1
-        self.p('}' + line)
+        self.p('}' + line, eat_nl=True)
 
     def write_doc_line(self, doc, indent=True):
         words = doc.split()
Signature · 1 line
2.40.1
author maintainer
#2 lore raw

PATCH v2 2/4 tools: ynl: user space helpers

In reply to Jakub Kicinski

Add "fixed" part of the user space Netlink Spec-based library. This will get linked with the protocol implementations to form a full API.

---
v2: fix up kdoc

---
 .../userspace-api/netlink/intro-specs.rst     |  79 ++
 tools/net/ynl/Makefile                        |  19 +
 tools/net/ynl/generated/Makefile              |  45 +
 tools/net/ynl/lib/Makefile                    |  28 +
 tools/net/ynl/lib/ynl.c                       | 901 ++++++++++++++++++
 tools/net/ynl/lib/ynl.h                       | 237 +++++
 tools/net/ynl/ynl-regen.sh                    |   2 +-
 7 files changed, 1310 insertions(+), 1 deletion(-)
 create mode 100644 tools/net/ynl/Makefile
 create mode 100644 tools/net/ynl/generated/Makefile
 create mode 100644 tools/net/ynl/lib/Makefile
 create mode 100644 tools/net/ynl/lib/ynl.c
 create mode 100644 tools/net/ynl/lib/ynl.h
Documentation/userspace-api/netlink/intro-specs.rst +79 -0
index a3b847eafff7..bada89699455 100644
@@ -78,3 +78,82 @@ to see other examples.
 The code generation itself is performed by ``tools/net/ynl/ynl-gen-c.py``
 but it takes a few arguments so calling it directly for each file
 quickly becomes tedious.
+
+YNL lib
+=======
+
+``tools/net/ynl/lib/`` contains an implementation of a C library
+(based on libmnl) which integrates with code generated by
+``tools/net/ynl/ynl-gen-c.py`` to create easy to use netlink wrappers.
+
+YNL basics
+----------
+
+The YNL library consists of two parts - the generic code (functions
+prefix by ``ynl_``) and per-family auto-generated code (prefixed
+with the name of the family).
+
+To create a YNL socket call ynl_sock_create() passing the family
+struct (family structs are exported by the auto-generated code).
+ynl_sock_destroy() closes the socket.
+
+YNL requests
+------------
+
+Steps for issuing YNL requests are best explained on an example.
+All the functions and types in this example come from the auto-generated
+code (for the netdev family in this case):
+
+.. code-block:: c
+
+   // 0. Request and response pointers
+   struct netdev_dev_get_req *req;
+   struct netdev_dev_get_rsp *d;
+
+   // 1. Allocate a request
+   req = netdev_dev_get_req_alloc();
+   // 2. Set request parameters (as needed)
+   netdev_dev_get_req_set_ifindex(req, ifindex);
+
+   // 3. Issues the request
+   d = netdev_dev_get(ys, req);
+   // 4. Free the request arguments
+   netdev_dev_get_req_free(req);
+   // 5. Error check (the return value from step 3)
+   if (!d) {
+	// 6. Print the YNL-generated error
+	fprintf(stderr, "YNL: %s\n", ys->err.msg);
+        return -1;
+   }
+
+   // ... do stuff with the response @d
+
+   // 7. Free response
+   netdev_dev_get_rsp_free(d);
+
+YNL dumps
+---------
+
+Performing dumps follows similar pattern as requests.
+Dumps return a list of objects terminated by a special marker,
+or NULL on error. Use ``ynl_dump_foreach()`` to iterate over
+the result.
+
+YNL notifications
+-----------------
+
+YNL lib supports using the same socket for notifications and
+requests. In case notifications arrive during processing of a request
+they are queued internally and can be retrieved at a later time.
+
+To subscribed to notifications use ``ynl_subscribe()``.
+The notifications have to be read out from the socket,
+``ynl_socket_get_fd()`` returns the underlying socket fd which can
+be plugged into appropriate asynchronous IO API like ``poll``,
+or ``select``.
+
+Notifications can be retrieved using ``ynl_ntf_dequeue()`` and have
+to be freed using ``ynl_ntf_free()``. Since we don't know the notification
+type upfront the notifications are returned as ``struct ynl_ntf_base_type *``
+and user is expected to cast them to the appropriate full type based
+on the ``cmd`` member.
tools/net/ynl/Makefile new file +19 -0
new file mode 100644
index 000000000000..d664b36deb5b
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: GPL-2.0
+
+SUBDIRS = lib generated samples
+
+all: $(SUBDIRS)
+
+$(SUBDIRS):
+	@if [ -f "$@/Makefile" ] ; then \
+		$(MAKE) -C $@ ; \
+	fi
+
+clean hardclean:
+	@for dir in $(SUBDIRS) ; do \
+		if [ -f "$$dir/Makefile" ] ; then \
+			$(MAKE) -C $$dir $@; \
+		fi \
+	done
+
+.PHONY: clean all $(SUBDIRS)
tools/net/ynl/generated/Makefile new file +45 -0

45 lines not on this page · raw message

tools/net/ynl/lib/Makefile new file +28 -0
new file mode 100644
index 000000000000..943021cc8eb3
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0
+
+CC=gcc
+CFLAGS=-std=gnu99 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow
+ifeq ("$(DEBUG)","1")
+  CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
+endif
+
+SRCS=$(wildcard *.c)
+OBJS=$(patsubst %.c,%.o,${SRCS})
+
+include $(wildcard *.d)
+
+all: ynl.a
+
+ynl.a: $(OBJS)
+	ar rcs $@ $(OBJS)
+clean:
+	rm -f *.o *.d *~
+
+hardclean: clean
+	rm -f *.a
+
+%.o: %.c
+	$(COMPILE.c) -MMD -c -o $@ $<
+
+.PHONY: all clean
+.DEFAULT_GOAL=all
tools/net/ynl/lib/ynl.c new file +901 -0

901 lines not on this page · raw message

tools/net/ynl/lib/ynl.h new file +237 -0

237 lines not on this page · raw message

tools/net/ynl/ynl-regen.sh +1 -1
index 74f5de1c2399..2a4525e2aa17 100755
@@ -14,7 +14,7 @@ done
 
 KDIR=$(dirname $(dirname $(dirname $(dirname $(realpath $0)))))
 
-files=$(git grep --files-with-matches '^/\* YNL-GEN \(kernel\|uapi\)')
+files=$(git grep --files-with-matches '^/\* YNL-GEN \(kernel\|uapi\|user\)')
 for f in $files; do
     # params:     0       1      2     3
     #         $YAML YNL-GEN kernel $mode
Signature · 1 line
2.40.1
#3 lore raw

Re: [PATCH net-next v2 2/4] tools: ynl: user space helpers

Quoted 72 lines · Jakub Kicinski

Add "fixed" part of the user space Netlink Spec-based library. This will get linked with the protocol implementations to form a full API.

---
v2: fix up kdoc

---
 .../userspace-api/netlink/intro-specs.rst     |  79 ++
 tools/net/ynl/Makefile                        |  19 +
 tools/net/ynl/generated/Makefile              |  45 +
 tools/net/ynl/lib/Makefile                    |  28 +
 tools/net/ynl/lib/ynl.c                       | 901 ++++++++++++++++++
 tools/net/ynl/lib/ynl.h                       | 237 +++++
 tools/net/ynl/ynl-regen.sh                    |   2 +-
 7 files changed, 1310 insertions(+), 1 deletion(-)
 create mode 100644 tools/net/ynl/Makefile
 create mode 100644 tools/net/ynl/generated/Makefile
 create mode 100644 tools/net/ynl/lib/Makefile
 create mode 100644 tools/net/ynl/lib/ynl.c
 create mode 100644 tools/net/ynl/lib/ynl.h
Documentation/userspace-api/netlink/intro-specs.rst +42 -0
index a3b847eafff7..bada89699455 100644
@@ -78,3 +78,82 @@ to see other examples.
 The code generation itself is performed by ``tools/net/ynl/ynl-gen-c.py``
 but it takes a few arguments so calling it directly for each file
 quickly becomes tedious.
+
+YNL lib
+=======
+
+``tools/net/ynl/lib/`` contains an implementation of a C library
+(based on libmnl) which integrates with code generated by
+``tools/net/ynl/ynl-gen-c.py`` to create easy to use netlink wrappers.
+
+YNL basics
+----------
+
+The YNL library consists of two parts - the generic code (functions
+prefix by ``ynl_``) and per-family auto-generated code (prefixed
+with the name of the family).
+
+To create a YNL socket call ynl_sock_create() passing the family
+struct (family structs are exported by the auto-generated code).
+ynl_sock_destroy() closes the socket.
+
+YNL requests
+------------
+
+Steps for issuing YNL requests are best explained on an example.
+All the functions and types in this example come from the auto-generated
+code (for the netdev family in this case):
+
+.. code-block:: c
+
+   // 0. Request and response pointers
+   struct netdev_dev_get_req *req;
+   struct netdev_dev_get_rsp *d;
+
+   // 1. Allocate a request
+   req = netdev_dev_get_req_alloc();
+   // 2. Set request parameters (as needed)
+   netdev_dev_get_req_set_ifindex(req, ifindex);
+
+   // 3. Issues the request
+   d = netdev_dev_get(ys, req);
+   // 4. Free the request arguments
+   netdev_dev_get_req_free(req);
+   // 5. Error check (the return value from step 3)

Documentation/userspace-api/netlink/intro-specs.rst to see other examples. · line 132

Quoted 10 lines
Documentation/userspace-api/netlink/intro-specs.rst +10 -0
+   if (!d) {
+	// 6. Print the YNL-generated error
+	fprintf(stderr, "YNL: %s\n", ys->err.msg);
+        return -1;
+   }
+
+   // ... do stuff with the response @d
+
+   // 7. Free response
+   netdev_dev_get_rsp_free(d);

General API question: do we have to have all those alloc/free calls? Why not have the following instead?

	struct netdev_dev_get_req req;
	struct netdev_dev_get_rsp rsp;
	
	netdev_dev_get_req_set_ifindex(&req, ifindex);
	netdev_dev_get(ys, &req, &rsp);

You seem to be doing malloc(*rsp) anyway in netdev_dev_get, so why not push that choice (heap/stack) on the users?

(haven't looked too closely at the series, so maybe a stupid question)

#4 lore raw

Re: [PATCH net-next v2 2/4] tools: ynl: user space helpers

Quoted 93 lines · Stanislav Fomichev
Quoted 72 lines · Jakub Kicinski

Add "fixed" part of the user space Netlink Spec-based library. This will get linked with the protocol implementations to form a full API.

---
v2: fix up kdoc

---
 .../userspace-api/netlink/intro-specs.rst     |  79 ++
 tools/net/ynl/Makefile                        |  19 +
 tools/net/ynl/generated/Makefile              |  45 +
 tools/net/ynl/lib/Makefile                    |  28 +
 tools/net/ynl/lib/ynl.c                       | 901 ++++++++++++++++++
 tools/net/ynl/lib/ynl.h                       | 237 +++++
 tools/net/ynl/ynl-regen.sh                    |   2 +-
 7 files changed, 1310 insertions(+), 1 deletion(-)
 create mode 100644 tools/net/ynl/Makefile
 create mode 100644 tools/net/ynl/generated/Makefile
 create mode 100644 tools/net/ynl/lib/Makefile
 create mode 100644 tools/net/ynl/lib/ynl.c
 create mode 100644 tools/net/ynl/lib/ynl.h
Documentation/userspace-api/netlink/intro-specs.rst +42 -0
index a3b847eafff7..bada89699455 100644
@@ -78,3 +78,82 @@ to see other examples.
 The code generation itself is performed by ``tools/net/ynl/ynl-gen-c.py``
 but it takes a few arguments so calling it directly for each file
 quickly becomes tedious.
+
+YNL lib
+=======
+
+``tools/net/ynl/lib/`` contains an implementation of a C library
+(based on libmnl) which integrates with code generated by
+``tools/net/ynl/ynl-gen-c.py`` to create easy to use netlink wrappers.
+
+YNL basics
+----------
+
+The YNL library consists of two parts - the generic code (functions
+prefix by ``ynl_``) and per-family auto-generated code (prefixed
+with the name of the family).
+
+To create a YNL socket call ynl_sock_create() passing the family
+struct (family structs are exported by the auto-generated code).
+ynl_sock_destroy() closes the socket.
+
+YNL requests
+------------
+
+Steps for issuing YNL requests are best explained on an example.
+All the functions and types in this example come from the auto-generated
+code (for the netdev family in this case):
+
+.. code-block:: c
+
+   // 0. Request and response pointers
+   struct netdev_dev_get_req *req;
+   struct netdev_dev_get_rsp *d;
+
+   // 1. Allocate a request
+   req = netdev_dev_get_req_alloc();
+   // 2. Set request parameters (as needed)
+   netdev_dev_get_req_set_ifindex(req, ifindex);
+
+   // 3. Issues the request
+   d = netdev_dev_get(ys, req);
+   // 4. Free the request arguments
+   netdev_dev_get_req_free(req);
+   // 5. Error check (the return value from step 3)

Documentation/userspace-api/netlink/intro-specs.rst to see other examples. · line 132

Quoted 10 lines
Documentation/userspace-api/netlink/intro-specs.rst +10 -0
+   if (!d) {
+	// 6. Print the YNL-generated error
+	fprintf(stderr, "YNL: %s\n", ys->err.msg);
+        return -1;
+   }
+
+   // ... do stuff with the response @d
+
+   // 7. Free response
+   netdev_dev_get_rsp_free(d);

General API question: do we have to have all those alloc/free calls? Why not have the following instead?

	struct netdev_dev_get_req req;
	struct netdev_dev_get_rsp rsp;
	
	netdev_dev_get_req_set_ifindex(&req, ifindex);
	netdev_dev_get(ys, &req, &rsp);
Quoted 4 lines

You seem to be doing malloc(*rsp) anyway in netdev_dev_get, so why not push that choice (heap/stack) on the users?

(haven't looked too closely at the series, so maybe a stupid question)

Answering to myself: netdev_dev_get_rsp is a simple case. With more involved responses, we might have variable data and pointers to different sub-chunks. So having netdev_dev_get-like getters do the allocations seems like a sensible option..

author maintainer
#5 lore raw

PATCH v2 3/4 tools: ynl: support fou and netdev in C

In reply to Jakub Kicinski

Generate the code for netdev and fou families. They are simple and already supported by the code gen.

---
 tools/net/ynl/generated/Makefile      |   2 +-
 tools/net/ynl/generated/fou-user.c    | 340 ++++++++++++++++++++++++++
 tools/net/ynl/generated/fou-user.h    | 337 +++++++++++++++++++++++++
 tools/net/ynl/generated/netdev-user.c | 250 +++++++++++++++++++
 tools/net/ynl/generated/netdev-user.h |  88 +++++++
 5 files changed, 1016 insertions(+), 1 deletion(-)
 create mode 100644 tools/net/ynl/generated/fou-user.c
 create mode 100644 tools/net/ynl/generated/fou-user.h
 create mode 100644 tools/net/ynl/generated/netdev-user.c
 create mode 100644 tools/net/ynl/generated/netdev-user.h
tools/net/ynl/generated/Makefile +1 -1
index 22f566eb095c..ef769e897922 100644
@@ -9,7 +9,7 @@ endif
 
 TOOL:=../ynl-gen-c.py
 
-GENS:=
+GENS:=fou netdev
 SRCS=$(patsubst %,%-user.c,${GENS})
 HDRS=$(patsubst %,%-user.h,${GENS})
 OBJS=$(patsubst %,%-user.o,${GENS})
tools/net/ynl/generated/fou-user.c new file +340 -0

340 lines not on this page · raw message

tools/net/ynl/generated/fou-user.h new file +337 -0

337 lines not on this page · raw message

tools/net/ynl/generated/netdev-user.c new file +250 -0

250 lines not on this page · raw message

tools/net/ynl/generated/netdev-user.h new file +88 -0

88 lines not on this page · raw message

Signature · 1 line
2.40.1
author maintainer
#6 lore raw

PATCH v2 4/4 tools: ynl: add sample for netdev

In reply to Jakub Kicinski

Add a sample application using the C library.
My main goal is to make writing selftests easier but until I have some of those ready I think it's useful to show off the functionality and let people poke and tinker.

Sample outputs - dump:

$ ./netdev
Select ifc ($ifindex; or 0 = dump; or -2 ntf check): 0
      lo[1]	0:
  enp1s0[2]	23: basic redirect rx-sg

Notifications (watching veth pair getting added and deleted):

$ ./netdev
Select ifc ($ifindex; or 0 = dump; or -2 ntf check): -2
[53]	0: (ntf: dev-add-ntf)
[54]	0: (ntf: dev-add-ntf)
[54]	23: basic redirect rx-sg (ntf: dev-change-ntf)
[53]	23: basic redirect rx-sg (ntf: dev-change-ntf)
[53]	23: basic redirect rx-sg (ntf: dev-del-ntf)
[54]	23: basic redirect rx-sg (ntf: dev-del-ntf)
---
 tools/net/ynl/samples/.gitignore |   1 +
 tools/net/ynl/samples/Makefile   |  28 ++++++++
 tools/net/ynl/samples/netdev.c   | 108 +++++++++++++++++++++++++++++++
 3 files changed, 137 insertions(+)
 create mode 100644 tools/net/ynl/samples/.gitignore
 create mode 100644 tools/net/ynl/samples/Makefile
 create mode 100644 tools/net/ynl/samples/netdev.c
tools/net/ynl/samples/.gitignore new file +1 -0
new file mode 100644
index 000000000000..7b1f5179cb54
@@ -0,0 +1 @@
+netdev
tools/net/ynl/samples/Makefile new file +28 -0
new file mode 100644
index 000000000000..54eb5e3b9ab4
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0
+
+CC=gcc
+CFLAGS=-std=gnu99 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \
+	-I../lib/ -I../generated/
+ifeq ("$(DEBUG)","1")
+  CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
+endif
+
+LDLIBS=-lmnl ../lib/ynl.a ../generated/protos.a
+
+SRCS=$(wildcard *.c)
+BINS=$(patsubst %.c,%,${SRCS})
+
+include $(wildcard *.d)
+
+all: $(BINS)
+
+$(BINS): ../lib/ynl.a ../generated/protos.a
+
+clean:
+	rm -f *.o *.d *~
+
+hardclean: clean
+	rm -f $(BINS)
+
+.PHONY: all clean
+.DEFAULT_GOAL=all
tools/net/ynl/samples/netdev.c new file +108 -0

108 lines not on this page · raw message

Signature · 1 line
2.40.1
#7 lore raw

RE: [PATCH net-next v2 4/4] tools: ynl: add sample for netdev

Quoted 46 lines · Jakub Kicinski

Add a sample application using the C library.
My main goal is to make writing selftests easier but until I have some of those ready I think it's useful to show off the functionality and let people poke and tinker.

Sample outputs - dump:

$ ./netdev
Select ifc ($ifindex; or 0 = dump; or -2 ntf check): 0
      lo[1]	0:
  enp1s0[2]	23: basic redirect rx-sg

Notifications (watching veth pair getting added and deleted):

$ ./netdev
Select ifc ($ifindex; or 0 = dump; or -2 ntf check): -2
[53]	0: (ntf: dev-add-ntf)
[54]	0: (ntf: dev-add-ntf)
[54]	23: basic redirect rx-sg (ntf: dev-change-ntf)
[53]	23: basic redirect rx-sg (ntf: dev-change-ntf)
[53]	23: basic redirect rx-sg (ntf: dev-del-ntf)
[54]	23: basic redirect rx-sg (ntf: dev-del-ntf)
---
 tools/net/ynl/samples/.gitignore |   1 +
 tools/net/ynl/samples/Makefile   |  28 ++++++++
 tools/net/ynl/samples/netdev.c   | 108 +++++++++++++++++++++++++++++++
 3 files changed, 137 insertions(+)
 create mode 100644 tools/net/ynl/samples/.gitignore
 create mode 100644 tools/net/ynl/samples/Makefile
 create mode 100644 tools/net/ynl/samples/netdev.c
tools/net/ynl/samples/.gitignore new file +1 -0
new file mode 100644
index 000000000000..7b1f5179cb54
@@ -0,0 +1 @@
+netdev
tools/net/ynl/samples/Makefile new file +0 -0
new file mode 100644
index 000000000000..54eb5e3b9ab4

tools/net/ynl/samples/Makefile line 5

Quoted 5 lines
tools/net/ynl/samples/Makefile new file +5 -0
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0
+
+CC=gcc
+CFLAGS=-std=gnu99 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \
+	-I../lib/ -I../generated/

Should new userspace code also use gnu11?

Quoted 23 lines
tools/net/ynl/samples/Makefile new file +23 -0
+ifeq ("$(DEBUG)","1")
+  CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
+endif
+
+LDLIBS=-lmnl ../lib/ynl.a ../generated/protos.a
+
+SRCS=$(wildcard *.c)
+BINS=$(patsubst %.c,%,${SRCS})
+
+include $(wildcard *.d)
+
+all: $(BINS)
+
+$(BINS): ../lib/ynl.a ../generated/protos.a
+
+clean:
+	rm -f *.o *.d *~
+
+hardclean: clean
+	rm -f $(BINS)
+
+.PHONY: all clean
+.DEFAULT_GOAL=all
author maintainer
#8 lore raw

Re: [PATCH net-next v2 4/4] tools: ynl: add sample for netdev

Quoted 4 lines · On Mon, 05 Jun 2023 05:31:52 -0400 Willem de Bruijn wrote:

tools/net/ynl/samples/Makefile line 5

Quoted 2 lines
tools/net/ynl/samples/Makefile new file +2 -0
+CFLAGS=-std=gnu99 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \
+	-I../lib/ -I../generated/  

Should new userspace code also use gnu11?

Well, 99.9% sure it doesn't matter, but okay. Let me send v3.

#9 lore raw

Re: [PATCH net-next v2 4/4] tools: ynl: add sample for netdev

Quoted 8 lines · Jakub Kicinski
Quoted 4 lines · On Mon, 05 Jun 2023 05:31:52 -0400 Willem de Bruijn wrote:

tools/net/ynl/samples/Makefile line 5

Quoted 2 lines
tools/net/ynl/samples/Makefile new file +2 -0
+CFLAGS=-std=gnu99 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \
+   -I../lib/ -I../generated/

Should new userspace code also use gnu11?

Well, 99.9% sure it doesn't matter, but okay. Let me send v3.

Thanks. Certainly not that important. I just figured it might set a good example for future userspace changes, to keep up with the kernel default.