Page MenuHomeFreeBSD

D56323.id175201.diff
No OneTemporary

D56323.id175201.diff

diff --git a/sys/netlink/netlink_snl_route_parsers.h b/sys/netlink/netlink_snl_route_parsers.h
--- a/sys/netlink/netlink_snl_route_parsers.h
+++ b/sys/netlink/netlink_snl_route_parsers.h
@@ -50,10 +50,11 @@
struct sockaddr *gw;
uint32_t ifindex;
uint8_t rtnh_flags;
- uint8_t rtnh_weight;
+ uint8_t rtnh_metric;
uint32_t rtax_mtu;
uint32_t rta_rtflags;
uint32_t rta_expire;
+ uint32_t rtnh_weight;
};
#define _IN(_field) offsetof(struct rtnexthop, _field)
@@ -66,6 +67,7 @@
static const struct snl_attr_parser _nla_p_mp_nh[] = {
{ .type = NL_RTA_GATEWAY, .off = _OUT(gw), .cb = snl_attr_get_ip },
{ .type = NL_RTA_METRICS, .arg = &_metrics_mp_nh_parser, .cb = snl_attr_get_nested },
+ { .type = NL_RTA_WEIGHT, .off = _OUT(rtnh_weight), .cb = snl_attr_get_uint32 },
{ .type = NL_RTA_RTFLAGS, .off = _OUT(rta_rtflags), .cb = snl_attr_get_uint32 },
{ .type = NL_RTA_VIA, .off = _OUT(gw), .cb = snl_attr_get_ipvia },
{ .type = NL_RTA_EXPIRES, .off = _OUT(rta_expire), .cb = snl_attr_get_uint32 },
@@ -73,7 +75,7 @@
static const struct snl_field_parser _fp_p_mp_nh[] = {
{ .off_in = _IN(rtnh_flags), .off_out = _OUT(rtnh_flags), .cb = snl_field_get_uint8 },
- { .off_in = _IN(rtnh_hops), .off_out = _OUT(rtnh_weight), .cb = snl_field_get_uint8 },
+ { .off_in = _IN(rtnh_hops), .off_out = _OUT(rtnh_metric), .cb = snl_field_get_uint8 },
{ .off_in = _IN(rtnh_ifindex), .off_out = _OUT(ifindex), .cb = snl_field_get_uint32 },
};
@@ -121,6 +123,7 @@
uint32_t rta_rtflags;
uint32_t rtax_mtu;
uint32_t rtax_weight;
+ uint8_t rta_metric;
uint8_t rtm_family;
uint8_t rtm_type;
uint8_t rtm_protocol;
@@ -138,6 +141,7 @@
{ .type = NL_RTA_DST, .off = _OUT(rta_dst), .cb = snl_attr_get_ip },
{ .type = NL_RTA_OIF, .off = _OUT(rta_oif), .cb = snl_attr_get_uint32 },
{ .type = NL_RTA_GATEWAY, .off = _OUT(rta_gw), .cb = snl_attr_get_ip },
+ { .type = NL_RTA_PRIORITY, .off = _OUT(rta_metric), .cb = snl_attr_get_uint8 },
{ .type = NL_RTA_METRICS, .arg = &_metrics_parser, .cb = snl_attr_get_nested },
{ .type = NL_RTA_MULTIPATH, .off = _OUT(rta_multipath), .cb = nlattr_get_multipath },
{ .type = NL_RTA_KNH_ID, .off = _OUT(rta_knh_id), .cb = snl_attr_get_uint32 },
diff --git a/sys/netlink/route/route.h b/sys/netlink/route/route.h
--- a/sys/netlink/route/route.h
+++ b/sys/netlink/route/route.h
@@ -149,7 +149,7 @@
NL_RTA_IIF = 3, /* not supported */
NL_RTA_OIF = 4, /* u32, transmit ifindex */
NL_RTA_GATEWAY = 5, /* binary: IPv4/IPv6 gateway */
- NL_RTA_PRIORITY = 6, /* not supported */
+ NL_RTA_PRIORITY = 6, /* u8, path metric */
NL_RTA_PREFSRC = 7, /* not supported */
NL_RTA_METRICS = 8, /* nested, list of NL_RTAX* attrs */
NL_RTA_MULTIPATH = 9, /* binary, array of struct rtnexthop */
@@ -333,7 +333,7 @@
struct rtnexthop {
unsigned short rtnh_len;
unsigned char rtnh_flags;
- unsigned char rtnh_hops; /* nexthop weight */
+ unsigned char rtnh_hops; /* nexthop metric */
int rtnh_ifindex;
};
diff --git a/sys/netlink/route/rt.c b/sys/netlink/route/rt.c
--- a/sys/netlink/route/rt.c
+++ b/sys/netlink/route/rt.c
@@ -182,6 +182,7 @@
struct nhop_object *nh;
uint32_t uidx, num_nhops, nh_expire;
uint32_t base_rtflags, rtflags, nhop_weight;
+ uint8_t nhop_metric;
MPASS((NH_IS_NHGRP(rnd->rnd_nhop)));
@@ -216,20 +217,23 @@
return;
rtnh->rtnh_flags = 0;
rtnh->rtnh_ifindex = if_getindex(wn[i].nh->nh_ifp);
- rtnh->rtnh_hops = wn[i].weight;
+ rtnh->rtnh_hops = wn[i].metric;
dump_rc_nhop_gw(nw, wn[i].nh);
- uint32_t rtflags = nhop_get_rtflags(wn[i].nh);
+ rtflags = nhop_get_rtflags(wn[i].nh);
if (rtflags != base_rtflags)
nlattr_add_u32(nw, NL_RTA_RTFLAGS, rtflags);
if (rtflags & RTF_FIXEDMTU)
dump_rc_nhop_mtu(nw, wn[i].nh);
+ nlattr_add_u32(nw, NL_RTA_WEIGHT, wn[i].pref);
nh_expire = nhop_get_expire(wn[i].nh);
if (nh_expire > 0)
nlattr_add_u32(nw, NL_RTA_EXPIRES, nh_expire - time_uptime);
rtnh = nlattr_restore_offset(nw, nh_off, struct rtnexthop);
- if (nh == wn[i].nh)
- nhop_weight = wn[i].weight;
+ if (nh == wn[i].nh) {
+ nhop_weight = wn[i].pref;
+ nhop_metric = wn[i].metric;
+ }
/*
* nlattr_add() allocates 4-byte aligned storage, no need to aligh
* length here
@@ -237,6 +241,7 @@
rtnh->rtnh_len = nlattr_save_offset(nw) - nh_off;
}
nlattr_set_len(nw, off);
+ nlattr_add_u8(nw, NL_RTA_PRIORITY, nhop_metric);
nlattr_add_u32(nw, NL_RTA_WEIGHT, nhop_weight);
}
@@ -278,8 +283,10 @@
/* In any case, fill outgoing interface */
nlattr_add_u32(nw, NL_RTA_OIF, if_getindex(nh->nh_ifp));
- if (rnd->rnd_weight != RT_DEFAULT_WEIGHT)
- nlattr_add_u32(nw, NL_RTA_WEIGHT, rnd->rnd_weight);
+ if (rnd->rnd_weight != RT_DEFAULT_WEIGHT) {
+ nlattr_add_u8(nw, NL_RTA_PRIORITY, rnd->rnd_metric);
+ nlattr_add_u32(nw, NL_RTA_WEIGHT, rnd->rnd_pref);
+ }
}
/*
@@ -424,18 +431,20 @@
struct sockaddr *gw;
struct ifnet *ifp;
uint8_t rtnh_flags;
- uint8_t rtnh_weight;
+ uint8_t rtnh_metric;
+ uint32_t rtnh_weight;
};
#define _IN(_field) offsetof(struct rtnexthop, _field)
#define _OUT(_field) offsetof(struct rta_mpath_nh, _field)
const static struct nlattr_parser nla_p_rtnh[] = {
{ .type = NL_RTA_GATEWAY, .off = _OUT(gw), .cb = nlattr_get_ip },
+ { .type = NL_RTA_WEIGHT, .off = _OUT(rtnh_weight), .cb = nlattr_get_uint32 },
{ .type = NL_RTA_VIA, .off = _OUT(gw), .cb = nlattr_get_ipvia },
};
const static struct nlfield_parser nlf_p_rtnh[] = {
{ .off_in = _IN(rtnh_flags), .off_out = _OUT(rtnh_flags), .cb = nlf_get_u8 },
- { .off_in = _IN(rtnh_hops), .off_out = _OUT(rtnh_weight), .cb = nlf_get_u8 },
+ { .off_in = _IN(rtnh_hops), .off_out = _OUT(rtnh_metric), .cb = nlf_get_u8 },
{ .off_in = _IN(rtnh_ifindex), .off_out = _OUT(ifp), .cb = nlf_get_ifpz },
};
#undef _IN
@@ -515,6 +524,7 @@
uint32_t rta_weight;
uint32_t rta_expire;
uint32_t rtax_mtu;
+ uint8_t rta_metric;
uint8_t rtm_table;
uint8_t rtm_family;
uint8_t rtm_dst_len;
@@ -534,6 +544,7 @@
{ .type = NL_RTA_DST, .off = _OUT(rta_dst), .cb = nlattr_get_ip },
{ .type = NL_RTA_OIF, .off = _OUT(rta_oif), .cb = nlattr_get_ifp },
{ .type = NL_RTA_GATEWAY, .off = _OUT(rta_gw), .cb = nlattr_get_ip },
+ { .type = NL_RTA_PRIORITY, .off = _OUT(rta_metric), .cb = nlattr_get_uint8 },
{ .type = NL_RTA_METRICS, .arg = &metrics_parser, .cb = nlattr_get_nested },
{ .type = NL_RTA_MULTIPATH, .off = _OUT(rta_multipath), .cb = nlattr_get_multipath },
{ .type = NL_RTA_WEIGHT, .off = _OUT(rta_weight), .cb = nlattr_get_uint32 },
@@ -892,7 +903,8 @@
nhop_free(wn[j].nh);
break;
}
- wn[i].weight = mpnh->rtnh_weight > 0 ? mpnh->rtnh_weight : 1;
+ wn[i].pref = mpnh->rtnh_weight > 0 ? mpnh->rtnh_weight : RT_DEFAULT_WEIGHT;
+ wn[i].metric = mpnh->rtnh_metric > 0 ? mpnh->rtnh_metric : 0;
}
if (error == 0) {
struct rib_head *rh = nhop_get_rh(wn[0].nh);
@@ -1003,7 +1015,11 @@
if (!NH_IS_NHGRP(nh) && attrs.rta_weight == 0)
attrs.rta_weight = RT_DEFAULT_WEIGHT;
- struct route_nhop_data rnd = { .rnd_nhop = nh, .rnd_weight = attrs.rta_weight };
+ struct route_nhop_data rnd = {
+ .rnd_nhop = nh,
+ .rnd_pref = attrs.rta_weight,
+ .rnd_metric = attrs.rta_metric,
+ };
int op_flags = get_op_flags(hdr->nlmsg_flags);
error = rib_add_route_px(attrs.rta_table, attrs.rta_dst, attrs.rtm_dst_len,

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 19, 3:11 PM (8 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31698159
Default Alt Text
D56323.id175201.diff (7 KB)

Event Timeline