From e68363909cb9733c1bf55fff80a8b034e4111849 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Fri, 16 Feb 2024 14:29:54 +0100 Subject: [PATCH] Netlink: Cleanups in route metrics - Add krt_fastopen_no_cookie atttibute - Add missing krt_lock_* bits - Fix krt_feature_allfrag - Fix type of EA_KRT_LOCK and EA_KRT_FEATURES --- doc/bird.sgml | 4 +++- sysdep/linux/krt-sys.h | 3 ++- sysdep/linux/netlink.Y | 22 +++++++++++++++++----- sysdep/linux/netlink.c | 14 +++++++++++--- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/doc/bird.sgml b/doc/bird.sgml index 5d59ae4d..79614188 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -3970,7 +3970,9 @@ string, others have type int. Supported attributes are: Example diff --git a/sysdep/linux/krt-sys.h b/sysdep/linux/krt-sys.h index 7c20a09e..484c90f8 100644 --- a/sysdep/linux/krt-sys.h +++ b/sysdep/linux/krt-sys.h @@ -39,7 +39,7 @@ static inline struct ifa * kif_get_primary_ip(struct iface *i UNUSED) { return N #define EA_KRT_SCOPE EA_CODE(PROTOCOL_KERNEL, 0x12) -#define KRT_METRICS_MAX 0x11 /* RTAX_CC_ALGO+1 */ +#define KRT_METRICS_MAX 0x12 /* RTAX_FASTOPEN_NO_COOKIE+1 */ #define KRT_METRICS_OFFSET 0x20 /* Offset of EA_KRT_* vs RTAX_* */ #define KRT_FEATURES_MAX 4 @@ -65,6 +65,7 @@ static inline struct ifa * kif_get_primary_ip(struct iface *i UNUSED) { return N #define EA_KRT_INITRWND EA_CODE(PROTOCOL_KERNEL, 0x2e) #define EA_KRT_QUICKACK EA_CODE(PROTOCOL_KERNEL, 0x2f) #define EA_KRT_CONGCTL EA_CODE(PROTOCOL_KERNEL, 0x30) +#define EA_KRT_FASTOPEN_NO_COOKIE EA_CODE(PROTOCOL_KERNEL, 0x31) struct krt_params { diff --git a/sysdep/linux/netlink.Y b/sysdep/linux/netlink.Y index 70b83daf..60ddfa96 100644 --- a/sysdep/linux/netlink.Y +++ b/sysdep/linux/netlink.Y @@ -14,9 +14,14 @@ CF_KEYWORDS(KERNEL, TABLE, METRIC, NETLINK, RX, BUFFER, KRT_PREFSRC, KRT_REALM, KRT_SCOPE, KRT_MTU, KRT_WINDOW, KRT_RTT, KRT_RTTVAR, KRT_SSTRESH, KRT_CWND, KRT_ADVMSS, KRT_REORDERING, KRT_HOPLIMIT, KRT_INITCWND, KRT_RTO_MIN, KRT_INITRWND, KRT_QUICKACK, - KRT_CONGCTL, KRT_LOCK_MTU, KRT_LOCK_WINDOW, KRT_LOCK_RTT, KRT_LOCK_RTTVAR, + KRT_CONGCTL, KRT_FASTOPEN_NO_COOKIE) + +CF_KEYWORDS(KRT_LOCK_MTU, KRT_LOCK_WINDOW, KRT_LOCK_RTT, KRT_LOCK_RTTVAR, KRT_LOCK_SSTRESH, KRT_LOCK_CWND, KRT_LOCK_ADVMSS, KRT_LOCK_REORDERING, - KRT_LOCK_HOPLIMIT, KRT_LOCK_RTO_MIN, KRT_FEATURE_ECN, KRT_FEATURE_ALLFRAG) + KRT_LOCK_HOPLIMIT, KRT_LOCK_INITCWND, KRT_LOCK_RTO_MIN, KRT_LOCK_INITRWND, + KRT_LOCK_QUICKACK, KRT_LOCK_CONGCTL, KRT_LOCK_FASTOPEN_NO_COOKIE, + KRT_FEATURE_ECN, KRT_FEATURE_ALLFRAG) + CF_GRAMMAR @@ -46,6 +51,7 @@ dynamic_attr: KRT_RTO_MIN { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_ dynamic_attr: KRT_INITRWND { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_INITRWND); } ; dynamic_attr: KRT_QUICKACK { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_QUICKACK); } ; dynamic_attr: KRT_CONGCTL { $$ = f_new_dynamic_attr(EAF_TYPE_STRING, T_STRING, EA_KRT_CONGCTL); } ; +dynamic_attr: KRT_FASTOPEN_NO_COOKIE { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_FASTOPEN_NO_COOKIE); } ; /* Bits of EA_KRT_LOCK, based on RTAX_* constants */ @@ -57,11 +63,17 @@ dynamic_attr: KRT_LOCK_SSTRESH { $$ = f_new_dynamic_attr_bit(6, T_BOOL, EA_KRT_L dynamic_attr: KRT_LOCK_CWND { $$ = f_new_dynamic_attr_bit(7, T_BOOL, EA_KRT_LOCK); } ; dynamic_attr: KRT_LOCK_ADVMSS { $$ = f_new_dynamic_attr_bit(8, T_BOOL, EA_KRT_LOCK); } ; dynamic_attr: KRT_LOCK_REORDERING { $$ = f_new_dynamic_attr_bit(9, T_BOOL, EA_KRT_LOCK); } ; -dynamic_attr: KRT_LOCK_HOPLIMIT { $$ = f_new_dynamic_attr_bit(10, T_BOOL, EA_KRT_LOCK); } ; -dynamic_attr: KRT_LOCK_RTO_MIN { $$ = f_new_dynamic_attr_bit(13, T_BOOL, EA_KRT_LOCK); } ; +dynamic_attr: KRT_LOCK_HOPLIMIT { $$ = f_new_dynamic_attr_bit(10, T_BOOL, EA_KRT_LOCK); } ; +dynamic_attr: KRT_LOCK_INITCWND { $$ = f_new_dynamic_attr_bit(11, T_BOOL, EA_KRT_LOCK); } ; +/* No lock for FEATURES bitfield */ +dynamic_attr: KRT_LOCK_RTO_MIN { $$ = f_new_dynamic_attr_bit(13, T_BOOL, EA_KRT_LOCK); } ; +dynamic_attr: KRT_LOCK_INITRWND { $$ = f_new_dynamic_attr_bit(14, T_BOOL, EA_KRT_LOCK); } ; +dynamic_attr: KRT_LOCK_QUICKACK { $$ = f_new_dynamic_attr_bit(15, T_BOOL, EA_KRT_LOCK); } ; +dynamic_attr: KRT_LOCK_CONGCTL { $$ = f_new_dynamic_attr_bit(16, T_BOOL, EA_KRT_LOCK); } ; +dynamic_attr: KRT_LOCK_FASTOPEN_NO_COOKIE { $$ = f_new_dynamic_attr_bit(17, T_BOOL, EA_KRT_LOCK); } ; dynamic_attr: KRT_FEATURE_ECN { $$ = f_new_dynamic_attr_bit(0, T_BOOL, EA_KRT_FEATURES); } ; -dynamic_attr: KRT_FEATURE_ALLFRAG { $$ = f_new_dynamic_attr(3, T_BOOL, EA_KRT_FEATURES); } ; +dynamic_attr: KRT_FEATURE_ALLFRAG { $$ = f_new_dynamic_attr_bit(3, T_BOOL, EA_KRT_FEATURES); } ; CF_CODE diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c index fb54de39..1ace6c27 100644 --- a/sysdep/linux/netlink.c +++ b/sysdep/linux/netlink.c @@ -1840,7 +1840,15 @@ nl_parse_route(struct nl_parse_state *s, struct nlmsghdr *h) for (t = 1; t < KRT_METRICS_MAX; t++) if (metrics[0] & (1 << t)) - if (t == RTAX_CC_ALGO) + if ((t == RTAX_LOCK) || (t == RTAX_FEATURES)) + { + ea->attrs[n++] = (eattr) { + .id = EA_KRT_METRICS + t, + .type = EAF_TYPE_BITFIELD, + .u.data = metrics[t], + }; + } + else if (t == RTAX_CC_ALGO) { struct adata *ad = lp_alloc_adata(s->pool, strlen(cc_algo)); memcpy(ad->data, cc_algo, ad->length); @@ -1855,7 +1863,7 @@ nl_parse_route(struct nl_parse_state *s, struct nlmsghdr *h) { ea->attrs[n++] = (eattr) { .id = EA_KRT_METRICS + t, - .type = EAF_TYPE_INT, /* FIXME: Some are EAF_TYPE_BITFIELD */ + .type = EAF_TYPE_INT, .u.data = metrics[t], }; } @@ -2142,7 +2150,7 @@ krt_sys_copy_config(struct krt_config *d, struct krt_config *s) static const char *krt_metrics_names[KRT_METRICS_MAX] = { NULL, "lock", "mtu", "window", "rtt", "rttvar", "sstresh", "cwnd", "advmss", "reordering", "hoplimit", "initcwnd", "features", "rto_min", "initrwnd", "quickack", - "congctl" + "congctl", "fastopen_no_cookie" }; static const char *krt_features_names[KRT_FEATURES_MAX] = {