($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: ell@lists.linux.dev
Subject: Re: [RFC PATCH 2/2] rtnl: Check if RTA_EXPIRES enum value is available
Date: Sun, 19 Nov 2023 17:50:47 +0100	[thread overview]
Message-ID: <5A84029F-7CEA-4F04-ABEA-389DE0D123A6@holtmann.org> (raw)
In-Reply-To: <20231111180753.51488-2-marcel@holtmann.org>

Hi,

> Work around the missing RTA_EXPIRES settings of really really old
> kernels and disable setting that attribute if the enum value is not
> present.
> ---
> acinclude.m4 | 15 +++++++++++++++
> configure.ac |  2 ++
> ell/rtnl.c   |  4 ++++
> 3 files changed, 21 insertions(+)
> 
> diff --git a/acinclude.m4 b/acinclude.m4
> index 6fb1de565a1d..3bb7b51d9ee6 100644
> --- a/acinclude.m4
> +++ b/acinclude.m4
> @@ -75,3 +75,18 @@ AC_DEFUN([COMPILER_FLAGS], [
> CFLAGS+=" -Wno-unknown-pragmas"
> fi
> ])
> +
> +AC_DEFUN([TEST_RTNL], [
> + AC_MSG_CHECKING([for RTA_EXPIRES])
> + AC_LANG_PUSH([C])
> + ac_rtnl_save_CFLAGS="$CFLAGS"
> + CFLAGS=""
> + AC_COMPILE_IFELSE([
> + AC_LANG_PROGRAM([#include <linux/rtnetlink.h>],
> + [enum rtattr_type_t t = RTA_EXPIRES;])],
> + AC_DEFINE(HAVE_RTA_EXPIRES, 1,
> + [Define to 1 if you have the RTA_EXPIRES enum value.])
> + AC_MSG_RESULT([yes]), AC_MSG_RESULT([no]))
> + CFLAGS=$ac_rtnl_save_CFLAGS
> + AC_LANG_POP([C])
> +])
> diff --git a/configure.ac b/configure.ac
> index cf3b53cfb574..44084bc4384b 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -111,6 +111,8 @@ AC_CHECK_FUNC(epoll_create, dummy=yes,
> 
> AC_CHECK_HEADERS(linux/types.h linux/if_alg.h)
> 
> +TEST_RTNL
> +
> AC_ARG_ENABLE(glib, AS_HELP_STRING([--enable-glib],
> [enable ell/glib main loop example]),
> [enable_glib=${enableval}])
> diff --git a/ell/rtnl.c b/ell/rtnl.c
> index ad2dca2f9e3c..5b392eae3fb3 100644
> --- a/ell/rtnl.c
> +++ b/ell/rtnl.c
> @@ -1348,7 +1348,9 @@ static uint32_t _rtnl_route_change(struct l_netlink *rtnl,
> size_t bufsize;
> void *rta_buf;
> uint16_t flags;
> +#ifdef HAVE_RTA_EXPIRES
> uint64_t now = l_time_now();
> +#endif
> 
> bufsize = NLMSG_ALIGN(sizeof(struct rtmsg)) +
> RTA_SPACE(sizeof(uint32_t)) +        /* RTA_OIF */
> @@ -1404,9 +1406,11 @@ static uint32_t _rtnl_route_change(struct l_netlink *rtnl,
> if (rt->preference)
> rta_buf += rta_add_u8(rta_buf, RTA_PREF, rt->preference);
> 
> +#ifdef HAVE_RTA_EXPIRES
> if (rt->expiry_time > now)
> rta_buf += rta_add_u32(rta_buf, RTA_EXPIRES,
> l_time_to_secs(rt->expiry_time - now));
> +#endif

while I think this is simple enough, it might make sense to actually add RTA_EXPIRES even if older kernels don’t support it.

What other obstacles do we have to get ELL compiled and working on older kernels?

Regards

Marcel


      reply	other threads:[~2023-11-19 16:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-11 18:07 [RFC PATCH 2/2] rtnl: Check if RTA_EXPIRES enum value is available Marcel Holtmann
2023-11-19 16:50 ` Marcel Holtmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5A84029F-7CEA-4F04-ABEA-389DE0D123A6@holtmann.org \
    --to=marcel@holtmann.org \
    --cc=ell@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).