Date: Tue, 21 Jan 2020 12:00:34 +0000 (UTC) From: "Alexander V. Chernikov" <melifaro@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356939 - in head/sys: net netinet6 Message-ID: <202001211200.00LC0YXn066386@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: melifaro Date: Tue Jan 21 12:00:34 2020 New Revision: 356939 URL: https://svnweb.freebsd.org/changeset/base/356939 Log: Document requirements for the 'struct route' variations. MFC after: 2 weeks Modified: head/sys/net/route_var.h head/sys/netinet6/in6_fib.c Modified: head/sys/net/route_var.h ============================================================================== --- head/sys/net/route_var.h Tue Jan 21 11:43:25 2020 (r356938) +++ head/sys/net/route_var.h Tue Jan 21 12:00:34 2020 (r356939) @@ -61,6 +61,30 @@ struct rib_head { #define RIB_LOCK_ASSERT(rh) rm_assert(&(rh)->rib_lock, RA_LOCKED) #define RIB_WLOCK_ASSERT(rh) rm_assert(&(rh)->rib_lock, RA_WLOCKED) +/* Macro for verifying fields in af-specific 'struct route' structures */ +#define CHK_STRUCT_FIELD_GENERIC(_s1, _f1, _s2, _f2) \ +_Static_assert(sizeof(((_s1 *)0)->_f1) == sizeof(((_s2 *)0)->_f2), \ + "Fields " #_f1 " and " #_f2 " size differs"); \ +_Static_assert(__offsetof(_s1, _f1) == __offsetof(_s2, _f2), \ + "Fields " #_f1 " and " #_f2 " offset differs"); + +#define _CHK_ROUTE_FIELD(_route_new, _field) \ + CHK_STRUCT_FIELD_GENERIC(struct route, _field, _route_new, _field) + +#define CHK_STRUCT_ROUTE_FIELDS(_route_new) \ + _CHK_ROUTE_FIELD(_route_new, ro_rt) \ + _CHK_ROUTE_FIELD(_route_new, ro_lle) \ + _CHK_ROUTE_FIELD(_route_new, ro_prepend)\ + _CHK_ROUTE_FIELD(_route_new, ro_plen) \ + _CHK_ROUTE_FIELD(_route_new, ro_flags) \ + _CHK_ROUTE_FIELD(_route_new, ro_mtu) \ + _CHK_ROUTE_FIELD(_route_new, spare) + +#define CHK_STRUCT_ROUTE_COMPAT(_ro_new, _dst_new) \ +CHK_STRUCT_ROUTE_FIELDS(_ro_new); \ +_Static_assert(__offsetof(struct route, ro_dst) == __offsetof(_ro_new, _dst_new),\ + "ro_dst and " #_dst_new " are at different offset") + struct rib_head *rt_tables_get_rnh(int fib, int family); /* rte<>nhop translation */ Modified: head/sys/netinet6/in6_fib.c ============================================================================== --- head/sys/netinet6/in6_fib.c Tue Jan 21 11:43:25 2020 (r356938) +++ head/sys/netinet6/in6_fib.c Tue Jan 21 12:00:34 2020 (r356939) @@ -75,6 +75,8 @@ static void fib6_rte_to_nh_basic(struct rtentry *rte, static struct ifnet *fib6_get_ifaifp(struct rtentry *rte); #define RNTORT(p) ((struct rtentry *)(p)) +CHK_STRUCT_ROUTE_COMPAT(struct route_in6, ro_dst); + /* * Gets real interface for the @rte. * Returns rt_ifp for !IFF_LOOPBACK routers.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001211200.00LC0YXn066386>