From: dsahern@kernel.org
To: netdev@vger.kernel.org
Cc: roopa@cumulusnetworks.com, David Ahern <dsahern@gmail.com>
Subject: [PATCH iproute2-next] ipaddress: Add support for address metric
Date: Sun, 27 May 2018 08:10:00 -0700 [thread overview]
Message-ID: <20180527151000.30488-9-dsahern@kernel.org> (raw)
In-Reply-To: <20180527151000.30488-1-dsahern@kernel.org>
From: David Ahern <dsahern@gmail.com>
Add support for IFA_RT_PRIORITY using the same keywords as iproute for
RTA_PRIORITY.
Signed-off-by: David Ahern <dsahern@gmail.com>
---
include/uapi/linux/if_addr.h | 1 +
ip/ipaddress.c | 15 ++++++++++++++-
man/man8/ip-address.8.in | 6 ++++++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/if_addr.h b/include/uapi/linux/if_addr.h
index c4899e22cdaa..a924606f36e5 100644
--- a/include/uapi/linux/if_addr.h
+++ b/include/uapi/linux/if_addr.h
@@ -33,6 +33,7 @@ enum {
IFA_CACHEINFO,
IFA_MULTICAST,
IFA_FLAGS,
+ IFA_RT_PRIORITY, /* u32, priority/metric for prefix route */
__IFA_MAX,
};
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 75539e057f6a..6b53b753ead9 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -63,7 +63,7 @@ static void usage(void)
fprintf(stderr, " ip address {showdump|restore}\n");
fprintf(stderr, "IFADDR := PREFIX | ADDR peer PREFIX\n");
fprintf(stderr, " [ broadcast ADDR ] [ anycast ADDR ]\n");
- fprintf(stderr, " [ label IFNAME ] [ scope SCOPE-ID ]\n");
+ fprintf(stderr, " [ label IFNAME ] [ scope SCOPE-ID ] [ metric METRIC ]\n");
fprintf(stderr, "SCOPE-ID := [ host | link | global | NUMBER ]\n");
fprintf(stderr, "FLAG-LIST := [ FLAG-LIST ] FLAG\n");
fprintf(stderr, "FLAG := [ permanent | dynamic | secondary | primary |\n");
@@ -1328,6 +1328,10 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n,
rta_tb[IFA_ADDRESS]));
}
print_int(PRINT_ANY, "prefixlen", "/%d ", ifa->ifa_prefixlen);
+
+ if (rta_tb[IFA_RT_PRIORITY])
+ print_uint(PRINT_ANY, "metric", "metric %u ",
+ rta_getattr_u32(rta_tb[IFA_RT_PRIORITY]));
}
if (brief)
@@ -2119,6 +2123,15 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
NEXT_ARG();
l = *argv;
addattr_l(&req.n, sizeof(req), IFA_LABEL, l, strlen(l)+1);
+ } else if (matches(*argv, "metric") == 0 ||
+ matches(*argv, "priority") == 0 ||
+ matches(*argv, "preference") == 0) {
+ __u32 metric;
+
+ NEXT_ARG();
+ if (get_u32(&metric, *argv, 0))
+ invarg("\"metric\" value is invalid\n", *argv);
+ addattr32(&req.n, sizeof(req), IFA_RT_PRIORITY, metric);
} else if (matches(*argv, "valid_lft") == 0) {
if (valid_lftp)
duparg("valid_lft", *argv);
diff --git a/man/man8/ip-address.8.in b/man/man8/ip-address.8.in
index 7ebf0bc98dcd..c3861b3725cc 100644
--- a/man/man8/ip-address.8.in
+++ b/man/man8/ip-address.8.in
@@ -27,6 +27,8 @@ ip-address \- protocol address management
.IR IFNAME " ] [ "
.B scope
.IR SCOPE-ID " ] [ "
+.B metric
+.IR METRIC " ] [ "
.B to
.IR PREFIX " ] [ " FLAG-LIST " ] [ "
.B label
@@ -215,6 +217,10 @@ valid inside this site.
.in -8
.TP
+.BI metric " NUMBER"
+priority of prefix route associated with address.
+
+.TP
.BI valid_lft " LFT"
the valid lifetime of this address; see section 5.5.4 of
RFC 4862. When it expires, the address is removed by the kernel.
--
2.11.0
next prev parent reply other threads:[~2018-05-27 15:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-27 15:09 [PATCH net-next 0/7] net: Add address attribute to control metric of prefix route dsahern
2018-05-27 15:09 ` [PATCH net-next 1/7] net/ipv6: Convert ipv6_add_addr to struct ifa6_config dsahern
2018-05-27 15:09 ` [PATCH net-next 2/7] net/ipv6: Pass ifa6_config struct to inet6_addr_add dsahern
2018-05-27 15:09 ` [PATCH net-next 3/7] net/ipv6: Pass ifa6_config struct to inet6_addr_modify dsahern
2018-05-27 15:09 ` [PATCH net-next 4/7] net: Add IFA_RT_PRIORITY address attribute dsahern
2018-05-27 15:09 ` [PATCH net-next 5/7] net/ipv4: Add support for specifying metric of connected routes dsahern
2018-05-27 15:09 ` [PATCH net-next 6/7] net/ipv6: " dsahern
2018-05-27 15:09 ` [PATCH net-next 7/7] selftests: fib_tests: Add prefix route tests with metric dsahern
2018-05-27 15:10 ` dsahern [this message]
2018-05-30 15:22 ` [PATCH iproute2-next] ipaddress: Add support for address metric David Ahern
2018-05-29 14:13 ` [PATCH net-next 0/7] net: Add address attribute to control metric of prefix route David Miller
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=20180527151000.30488-9-dsahern@kernel.org \
--to=dsahern@kernel.org \
--cc=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=roopa@cumulusnetworks.com \
/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 NNTP newsgroup(s).