History

ipv6: add ip6_del_rt_reason()

Add RTA_DEL_REASON and enum rt_del_reason to the rtnetlink uAPI, and add ip6_del_rt_reason(), which takes the reason a route is being deleted. It has no skip_notify argument: a caller that records a deletion reason wants the notification that carries it. The reason is unused for now. Subsequent patches propagate it to the deletion path and report it on RTM_DELROUTE.

Yuyang Huang committed 3 months ago

Commit cc17e381 parent f6057f03 files · +35 −0Browse files

Unified · Split

3 files
  1. include/net/ip6_route.h +2 −0
  2. include/uapi/linux/rtnetlink.h +25 −0
  3. net/ipv6/route.c +8 −0
include/net/ip6_route.h+2−0
@@ -126,6 +126,8 @@ int ipv6_route_ioctl(struct net *net, unsigned int cmd, · 125 unmodified lines
126int ip6_route_add(struct fib6_config *cfg, gfp_t gfp_flags,126int ip6_route_add(struct fib6_config *cfg, gfp_t gfp_flags,
127 struct netlink_ext_ack *extack);127 struct netlink_ext_ack *extack);
128int ip6_ins_rt(struct net *net, struct fib6_info *f6i);128int ip6_ins_rt(struct net *net, struct fib6_info *f6i);
129int ip6_del_rt_reason(struct net *net, struct fib6_info *f6i,
130 enum rt_del_reason del_reason);
129#if IS_ENABLED(CONFIG_IPV6)131#if IS_ENABLED(CONFIG_IPV6)
130int ip6_del_rt(struct net *net, struct fib6_info *f6i, bool skip_notify);132int ip6_del_rt(struct net *net, struct fib6_info *f6i, bool skip_notify);
131#else133#else
include/uapi/linux/rtnetlink.h+25−0
@@ -399,6 +399,7 @@ enum rtattr_type_t { · 398 unmodified lines
399 RTA_DPORT,399 RTA_DPORT,
400 RTA_NH_ID,400 RTA_NH_ID,
401 RTA_FLOWLABEL,401 RTA_FLOWLABEL,
402 RTA_DEL_REASON,
402 __RTA_MAX403 __RTA_MAX
403};404};
404 405
@@ -407,6 +408,30 @@ enum rtattr_type_t { · 2 unmodified lines
407#define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))408#define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
408#define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))409#define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
409 410
411/* RTA_DEL_REASON: why the kernel deleted the route. u32.
412 * Emitted only on RTM_DELROUTE notifications, and only when the deletion
413 * path records a cause. Absence means either an older kernel or a
414 * deletion path that does not (yet) record its cause - consumers must
415 * treat "absent" and "unspec" identically. New causes may be appended.
416 * Currently only IPv6 deletion paths record a cause.
417 *
418 * The attribute is notification-only: the kernel rejects it in
419 * requests, so a notification must not be echoed back verbatim.
420 *
421 * The value space is family-agnostic: a value must never be
422 * reinterpreted per address family. A cause that only one family can
423 * produce still gets its own value rather than reusing another
424 * family's.
425 */
426enum rt_del_reason {
427 RT_DEL_REASON_UNSPEC, /* cause not recorded */
428 RT_DEL_REASON_EXPIRED, /* RTF_EXPIRES lifetime ran out (GC) */
429 RT_DEL_REASON_RA_WITHDRAWN, /* zero-lifetime RA / PIO / RIO */
430 __RT_DEL_REASON_MAX
431};
432
433#define RT_DEL_REASON_MAX (__RT_DEL_REASON_MAX - 1)
434
410/* RTM_MULTIPATH --- array of struct rtnexthop.435/* RTM_MULTIPATH --- array of struct rtnexthop.
411 *436 *
412 * "struct rtnexthop" describes all necessary nexthop information,437 * "struct rtnexthop" describes all necessary nexthop information,
net/ipv6/route.c+8−0
@@ -4004,6 +4004,14 @@ int ip6_del_rt(struct net *net, struct fib6_info *rt, bool skip_notify) · 4003 unmodified lines
4004 return __ip6_del_rt(rt, &info);4004 return __ip6_del_rt(rt, &info);
4005}4005}
4006 4006
4007int ip6_del_rt_reason(struct net *net, struct fib6_info *rt,
4008 enum rt_del_reason del_reason)
4009{
4010 struct nl_info info = { .nl_net = net };
4011
4012 return __ip6_del_rt(rt, &info);
4013}
4014
4007static int __ip6_del_rt_siblings(struct fib6_info *rt, struct fib6_config *cfg)4015static int __ip6_del_rt_siblings(struct fib6_info *rt, struct fib6_config *cfg)
4008{4016{
4009 struct nl_info *info = &cfg->fc_nlinfo;4017 struct nl_info *info = &cfg->fc_nlinfo;