network: introduce ip nexthop routing
Used to manipulate entries in the kernel's nexthop tables. Example: ``` [NextHop] Id=3 Gateway=192.168.5.1 ```
This commit is contained in:
committed by
Yu Watanabe
parent
55d3fdcf5e
commit
c16c780804
@@ -0,0 +1,56 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
#ifndef _LINUX_NEXTHOP_H
|
||||
#define _LINUX_NEXTHOP_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
struct nhmsg {
|
||||
unsigned char nh_family;
|
||||
unsigned char nh_scope; /* return only */
|
||||
unsigned char nh_protocol; /* Routing protocol that installed nh */
|
||||
unsigned char resvd;
|
||||
unsigned int nh_flags; /* RTNH_F flags */
|
||||
};
|
||||
|
||||
/* entry in a nexthop group */
|
||||
struct nexthop_grp {
|
||||
__u32 id; /* nexthop id - must exist */
|
||||
__u8 weight; /* weight of this nexthop */
|
||||
__u8 resvd1;
|
||||
__u16 resvd2;
|
||||
};
|
||||
|
||||
enum {
|
||||
NEXTHOP_GRP_TYPE_MPATH, /* default type if not specified */
|
||||
__NEXTHOP_GRP_TYPE_MAX,
|
||||
};
|
||||
|
||||
#define NEXTHOP_GRP_TYPE_MAX (__NEXTHOP_GRP_TYPE_MAX - 1)
|
||||
|
||||
enum {
|
||||
NHA_UNSPEC,
|
||||
NHA_ID, /* u32; id for nexthop. id == 0 means auto-assign */
|
||||
|
||||
NHA_GROUP, /* array of nexthop_grp */
|
||||
NHA_GROUP_TYPE, /* u16 one of NEXTHOP_GRP_TYPE */
|
||||
/* if NHA_GROUP attribute is added, no other attributes can be set */
|
||||
|
||||
NHA_BLACKHOLE, /* flag; nexthop used to blackhole packets */
|
||||
/* if NHA_BLACKHOLE is added, OIF, GATEWAY, ENCAP can not be set */
|
||||
|
||||
NHA_OIF, /* u32; nexthop device */
|
||||
NHA_GATEWAY, /* be32 (IPv4) or in6_addr (IPv6) gw address */
|
||||
NHA_ENCAP_TYPE, /* u16; lwt encap type */
|
||||
NHA_ENCAP, /* lwt encap data */
|
||||
|
||||
/* NHA_OIF can be appended to dump request to return only
|
||||
* nexthops using given device
|
||||
*/
|
||||
NHA_GROUPS, /* flag; only return nexthop groups in dump */
|
||||
NHA_MASTER, /* u32; only return nexthops with given master dev */
|
||||
|
||||
__NHA_MAX,
|
||||
};
|
||||
|
||||
#define NHA_MAX (__NHA_MAX - 1)
|
||||
#endif
|
||||
@@ -157,6 +157,13 @@ enum {
|
||||
RTM_GETCHAIN,
|
||||
#define RTM_GETCHAIN RTM_GETCHAIN
|
||||
|
||||
RTM_NEWNEXTHOP = 104,
|
||||
#define RTM_NEWNEXTHOP RTM_NEWNEXTHOP
|
||||
RTM_DELNEXTHOP,
|
||||
#define RTM_DELNEXTHOP RTM_DELNEXTHOP
|
||||
RTM_GETNEXTHOP,
|
||||
#define RTM_GETNEXTHOP RTM_GETNEXTHOP
|
||||
|
||||
__RTM_MAX,
|
||||
#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
|
||||
};
|
||||
@@ -165,7 +172,7 @@ enum {
|
||||
#define RTM_NR_FAMILIES (RTM_NR_MSGTYPES >> 2)
|
||||
#define RTM_FAM(cmd) (((cmd) - RTM_BASE) >> 2)
|
||||
|
||||
/*
|
||||
/*
|
||||
Generic structure for encapsulation of optional route information.
|
||||
It is reminiscent of sockaddr, but with sa_family replaced
|
||||
with attribute type.
|
||||
@@ -205,7 +212,7 @@ struct rtmsg {
|
||||
|
||||
unsigned char rtm_table; /* Routing table id */
|
||||
unsigned char rtm_protocol; /* Routing protocol; see below */
|
||||
unsigned char rtm_scope; /* See below */
|
||||
unsigned char rtm_scope; /* See below */
|
||||
unsigned char rtm_type; /* See below */
|
||||
|
||||
unsigned rtm_flags;
|
||||
@@ -342,6 +349,7 @@ enum rtattr_type_t {
|
||||
RTA_IP_PROTO,
|
||||
RTA_SPORT,
|
||||
RTA_DPORT,
|
||||
RTA_NH_ID,
|
||||
__RTA_MAX
|
||||
};
|
||||
|
||||
@@ -515,7 +523,7 @@ struct ifinfomsg {
|
||||
};
|
||||
|
||||
/********************************************************************
|
||||
* prefix information
|
||||
* prefix information
|
||||
****/
|
||||
|
||||
struct prefixmsg {
|
||||
@@ -529,7 +537,7 @@ struct prefixmsg {
|
||||
unsigned char prefix_pad3;
|
||||
};
|
||||
|
||||
enum
|
||||
enum
|
||||
{
|
||||
PREFIX_UNSPEC,
|
||||
PREFIX_ADDRESS,
|
||||
@@ -704,6 +712,8 @@ enum rtnetlink_groups {
|
||||
#define RTNLGRP_IPV4_MROUTE_R RTNLGRP_IPV4_MROUTE_R
|
||||
RTNLGRP_IPV6_MROUTE_R,
|
||||
#define RTNLGRP_IPV6_MROUTE_R RTNLGRP_IPV6_MROUTE_R
|
||||
RTNLGRP_NEXTHOP,
|
||||
#define RTNLGRP_NEXTHOP RTNLGRP_NEXTHOP
|
||||
__RTNLGRP_MAX
|
||||
};
|
||||
#define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
|
||||
|
||||
Reference in New Issue
Block a user