Message ID | 20220729085035.535788-3-wojciech.drewek@intel.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | David Ahern |
Headers | show |
Series | PPPoE support in tc-flower | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On Fri, Jul 29, 2022 at 10:50:34AM +0200, Wojciech Drewek wrote: > PPP protocol field uses different values than ethertype. Introduce > utilities for translating PPP protocols from strings to values > and vice versa. Use generic API from utils in order to get > proto id and name. Acked-by: Guillaume Nault <gnault@redhat.com>
On 7/29/22 2:50 AM, Wojciech Drewek wrote: > PPP protocol field uses different values than ethertype. Introduce > utilities for translating PPP protocols from strings to values > and vice versa. Use generic API from utils in order to get > proto id and name. > > Signed-off-by: Wojciech Drewek <wojciech.drewek@intel.com> > --- > v4: ppp_defs.h removed > --- > include/rt_names.h | 3 +++ > lib/Makefile | 2 +- > lib/ppp_proto.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 56 insertions(+), 1 deletion(-) > create mode 100644 lib/ppp_proto.c > Ubuntu 20.04 with gcc 9.4 and clang 10.0 - both fail the same: $ make lib CC ppp_proto.o In file included from ppp_proto.c:9: ../include/uapi/linux/ppp_defs.h:151:5: error: unknown type name ‘__kernel_old_time_t’ 151 | __kernel_old_time_t xmit_idle; /* time since last NP packet sent */ | ^~~~~~~~~~~~~~~~~~~ ../include/uapi/linux/ppp_defs.h:152:5: error: unknown type name ‘__kernel_old_time_t’ 152 | __kernel_old_time_t recv_idle; /* time since last NP packet received */ | ^~~~~~~~~~~~~~~~~~~ make[1]: *** [../config.mk:58: ppp_proto.o] Error 1 make: *** [Makefile:77: all] Error 2
On Fri, Jul 29, 2022 at 08:58:07AM -0600, David Ahern wrote: > On 7/29/22 2:50 AM, Wojciech Drewek wrote: > > PPP protocol field uses different values than ethertype. Introduce > > utilities for translating PPP protocols from strings to values > > and vice versa. Use generic API from utils in order to get > > proto id and name. > > > > Signed-off-by: Wojciech Drewek <wojciech.drewek@intel.com> > > --- > > v4: ppp_defs.h removed > > --- > > include/rt_names.h | 3 +++ > > lib/Makefile | 2 +- > > lib/ppp_proto.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ > > 3 files changed, 56 insertions(+), 1 deletion(-) > > create mode 100644 lib/ppp_proto.c > > > > Ubuntu 20.04 with gcc 9.4 and clang 10.0 - both fail the same: > > $ make > > lib > CC ppp_proto.o > In file included from ppp_proto.c:9: > ../include/uapi/linux/ppp_defs.h:151:5: error: unknown type name > ‘__kernel_old_time_t’ > 151 | __kernel_old_time_t xmit_idle; /* time since last NP packet > sent */ > | ^~~~~~~~~~~~~~~~~~~ > ../include/uapi/linux/ppp_defs.h:152:5: error: unknown type name > ‘__kernel_old_time_t’ > 152 | __kernel_old_time_t recv_idle; /* time since last NP packet > received */ > | ^~~~~~~~~~~~~~~~~~~ > make[1]: *** [../config.mk:58: ppp_proto.o] Error 1 > make: *** [Makefile:77: all] Error 2 Works for me on Debian 11 (Bullseye), where __kernel_old_time_t is defined in /usr/include/asm-generic/posix_types.h (package linux-libc-dev). I guess the Ubuntu 20.04 failure happens because it's based on Linux 5.4, while __kernel_old_time_t was introduced in v5.5 (by commit 94c467ddb273 ("y2038: add __kernel_old_timespec and __kernel_old_time_t")). Not sure how to resolve this. This series doesn't need the struct ppp_idle that depends on __kernel_old_time_t.
On 7/29/22 10:03 AM, Guillaume Nault wrote: > On Fri, Jul 29, 2022 at 08:58:07AM -0600, David Ahern wrote: >> On 7/29/22 2:50 AM, Wojciech Drewek wrote: >>> PPP protocol field uses different values than ethertype. Introduce >>> utilities for translating PPP protocols from strings to values >>> and vice versa. Use generic API from utils in order to get >>> proto id and name. >>> >>> Signed-off-by: Wojciech Drewek <wojciech.drewek@intel.com> >>> --- >>> v4: ppp_defs.h removed >>> --- >>> include/rt_names.h | 3 +++ >>> lib/Makefile | 2 +- >>> lib/ppp_proto.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ >>> 3 files changed, 56 insertions(+), 1 deletion(-) >>> create mode 100644 lib/ppp_proto.c >>> >> >> Ubuntu 20.04 with gcc 9.4 and clang 10.0 - both fail the same: >> >> $ make >> >> lib >> CC ppp_proto.o >> In file included from ppp_proto.c:9: >> ../include/uapi/linux/ppp_defs.h:151:5: error: unknown type name >> ‘__kernel_old_time_t’ >> 151 | __kernel_old_time_t xmit_idle; /* time since last NP packet >> sent */ >> | ^~~~~~~~~~~~~~~~~~~ >> ../include/uapi/linux/ppp_defs.h:152:5: error: unknown type name >> ‘__kernel_old_time_t’ >> 152 | __kernel_old_time_t recv_idle; /* time since last NP packet >> received */ >> | ^~~~~~~~~~~~~~~~~~~ >> make[1]: *** [../config.mk:58: ppp_proto.o] Error 1 >> make: *** [Makefile:77: all] Error 2 > > Works for me on Debian 11 (Bullseye), where __kernel_old_time_t is > defined in /usr/include/asm-generic/posix_types.h (package > linux-libc-dev). > > I guess the Ubuntu 20.04 failure happens because it's based on > Linux 5.4, while __kernel_old_time_t was introduced in v5.5 (by > commit 94c467ddb273 ("y2038: add __kernel_old_timespec and > __kernel_old_time_t")). > > Not sure how to resolve this. This series doesn't need the > struct ppp_idle that depends on __kernel_old_time_t. > I can fix this by importing posix_types.h from kernel headers.
diff --git a/include/rt_names.h b/include/rt_names.h index 1835f3be2bed..6358650db404 100644 --- a/include/rt_names.h +++ b/include/rt_names.h @@ -31,6 +31,9 @@ int ll_addr_a2n(char *lladdr, int len, const char *arg); const char * ll_proto_n2a(unsigned short id, char *buf, int len); int ll_proto_a2n(unsigned short *id, const char *buf); +const char *ppp_proto_n2a(unsigned short id, char *buf, int len); +int ppp_proto_a2n(unsigned short *id, const char *buf); + const char *nl_proto_n2a(int id, char *buf, int len); int nl_proto_a2n(__u32 *id, const char *arg); diff --git a/lib/Makefile b/lib/Makefile index 6c98f9a61fdb..ddedd37feb32 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -5,7 +5,7 @@ CFLAGS += -fPIC UTILOBJ = utils.o utils_math.o rt_names.o ll_map.o ll_types.o ll_proto.o ll_addr.o \ inet_proto.o namespace.o json_writer.o json_print.o json_print_math.o \ - names.o color.o bpf_legacy.o bpf_glue.o exec.o fs.o cg_map.o + names.o color.o bpf_legacy.o bpf_glue.o exec.o fs.o cg_map.o ppp_proto.o ifeq ($(HAVE_ELF),y) ifeq ($(HAVE_LIBBPF),y) diff --git a/lib/ppp_proto.c b/lib/ppp_proto.c new file mode 100644 index 000000000000..a63466432888 --- /dev/null +++ b/lib/ppp_proto.c @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Utilities for translating PPP protocols from strings + * and vice versa. + * + * Authors: Wojciech Drewek <wojciech.drewek@intel.com> + */ + +#include <linux/ppp_defs.h> +#include <linux/if_ether.h> +#include "utils.h" +#include "rt_names.h" + +static const struct proto ppp_proto_names[] = { + {PPP_IP, "ip"}, + {PPP_AT, "at"}, + {PPP_IPX, "ipx"}, + {PPP_VJC_COMP, "vjc_comp"}, + {PPP_VJC_UNCOMP, "vjc_uncomp"}, + {PPP_MP, "mp"}, + {PPP_IPV6, "ipv6"}, + {PPP_COMPFRAG, "compfrag"}, + {PPP_COMP, "comp"}, + {PPP_MPLS_UC, "mpls_uc"}, + {PPP_MPLS_MC, "mpls_mc"}, + {PPP_IPCP, "ipcp"}, + {PPP_ATCP, "atcp"}, + {PPP_IPXCP, "ipxcp"}, + {PPP_IPV6CP, "ipv6cp"}, + {PPP_CCPFRAG, "ccpfrag"}, + {PPP_CCP, "ccp"}, + {PPP_MPLSCP, "mplscp"}, + {PPP_LCP, "lcp"}, + {PPP_PAP, "pap"}, + {PPP_LQR, "lqr"}, + {PPP_CHAP, "chap"}, + {PPP_CBCP, "cbcp"}, +}; + +const char *ppp_proto_n2a(unsigned short id, char *buf, int len) +{ + size_t len_tb = ARRAY_SIZE(ppp_proto_names); + + return proto_n2a(id, buf, len, ppp_proto_names, len_tb); +} + +int ppp_proto_a2n(unsigned short *id, const char *buf) +{ + size_t len_tb = ARRAY_SIZE(ppp_proto_names); + + return proto_a2n(id, buf, ppp_proto_names, len_tb); +}
PPP protocol field uses different values than ethertype. Introduce utilities for translating PPP protocols from strings to values and vice versa. Use generic API from utils in order to get proto id and name. Signed-off-by: Wojciech Drewek <wojciech.drewek@intel.com> --- v4: ppp_defs.h removed --- include/rt_names.h | 3 +++ lib/Makefile | 2 +- lib/ppp_proto.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 lib/ppp_proto.c