📄 iproute2.diff
字号:
union { struct {@@ -446,6 +462,7 @@ NDA_DST, NDA_LLADDR, NDA_CACHEINFO,+ NDA_PROBES, __NDA_MAX }; @@ -486,6 +503,106 @@ __u32 ndm_refcnt; }; ++/*****************************************************************+ * Neighbour tables specific messages.+ *+ * To retrieve the neighbour tables send RTM_GETNEIGHTBL with the+ * NLM_F_DUMP flag set. Every neighbour table configuration is+ * spread over multiple messages to avoid running into message+ * size limits on systems with many interfaces. The first message+ * in the sequence transports all not device specific data such as+ * statistics, configuration, and the default parameter set.+ * This message is followed by 0..n messages carrying device+ * specific parameter sets.+ * Although the ordering should be sufficient, NDTA_NAME can be+ * used to identify sequences. The initial message can be identified+ * by checking for NDTA_CONFIG. The device specific messages do+ * not contain this TLV but have NDTPA_IFINDEX set to the+ * corresponding interface index.+ *+ * To change neighbour table attributes, send RTM_SETNEIGHTBL+ * with NDTA_NAME set. Changeable attribute include NDTA_THRESH[1-3],+ * NDTA_GC_INTERVAL, and all TLVs in NDTA_PARMS unless marked+ * otherwise. Device specific parameter sets can be changed by+ * setting NDTPA_IFINDEX to the interface index of the corresponding+ * device.+ ****/++struct ndt_stats+{+ __u64 ndts_allocs;+ __u64 ndts_destroys;+ __u64 ndts_hash_grows;+ __u64 ndts_res_failed;+ __u64 ndts_lookups;+ __u64 ndts_hits;+ __u64 ndts_rcv_probes_mcast;+ __u64 ndts_rcv_probes_ucast;+ __u64 ndts_periodic_gc_runs;+ __u64 ndts_forced_gc_runs;+};++enum {+ NDTPA_UNSPEC,+ NDTPA_IFINDEX, /* u32, unchangeable */+ NDTPA_REFCNT, /* u32, read-only */+ NDTPA_REACHABLE_TIME, /* u64, read-only, msecs */+ NDTPA_BASE_REACHABLE_TIME, /* u64, msecs */+ NDTPA_RETRANS_TIME, /* u64, msecs */+ NDTPA_GC_STALETIME, /* u64, msecs */+ NDTPA_DELAY_PROBE_TIME, /* u64, msecs */+ NDTPA_QUEUE_LEN, /* u32 */+ NDTPA_APP_PROBES, /* u32 */+ NDTPA_UCAST_PROBES, /* u32 */+ NDTPA_MCAST_PROBES, /* u32 */+ NDTPA_ANYCAST_DELAY, /* u64, msecs */+ NDTPA_PROXY_DELAY, /* u64, msecs */+ NDTPA_PROXY_QLEN, /* u32 */+ NDTPA_LOCKTIME, /* u64, msecs */+ __NDTPA_MAX+};+#define NDTPA_MAX (__NDTPA_MAX - 1)++struct ndtmsg+{+ __u8 ndtm_family;+ __u8 ndtm_pad1;+ __u16 ndtm_pad2;+};++struct ndt_config+{+ __u16 ndtc_key_len;+ __u16 ndtc_entry_size;+ __u32 ndtc_entries;+ __u32 ndtc_last_flush; /* delta to now in msecs */+ __u32 ndtc_last_rand; /* delta to now in msecs */+ __u32 ndtc_hash_rnd;+ __u32 ndtc_hash_mask;+ __u32 ndtc_hash_chain_gc;+ __u32 ndtc_proxy_qlen;+};++enum {+ NDTA_UNSPEC,+ NDTA_NAME, /* char *, unchangeable */+ NDTA_THRESH1, /* u32 */+ NDTA_THRESH2, /* u32 */+ NDTA_THRESH3, /* u32 */+ NDTA_CONFIG, /* struct ndt_config, read-only */+ NDTA_PARMS, /* nested TLV NDTPA_* */+ NDTA_STATS, /* struct ndt_stats, read-only */+ NDTA_GC_INTERVAL, /* u64, msecs */+ __NDTA_MAX+};+#define NDTA_MAX (__NDTA_MAX - 1)++#define NDTA_RTA(r) ((struct rtattr*)(((char*)(r)) + \+ NLMSG_ALIGN(sizeof(struct ndtmsg))))+#define NDTA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg))++ /**** * General form of address family dependent message. ****/@@ -521,10 +638,13 @@ struct prefixmsg { unsigned char prefix_family;+ unsigned char prefix_pad1;+ unsigned short prefix_pad2; int prefix_ifindex; unsigned char prefix_type; unsigned char prefix_len; unsigned char prefix_flags;+ unsigned char prefix_pad3; }; enum @@ -708,7 +828,6 @@ #define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg)))) #define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg)) - /* RTnetlink multicast groups */ #define RTMGRP_LINK 1@@ -725,25 +844,24 @@ #define RTMGRP_IPV6_ROUTE 0x400 #define RTMGRP_IPV6_IFINFO 0x800 -#define RTMGRP_DECnet_IFADDR 0x1000-#define RTMGRP_DECnet_ROUTE 0x4000+#define RTMGRP_DECnet_IFADDR 0x1000+#define RTMGRP_DECnet_ROUTE 0x4000 #define RTMGRP_IPV6_PREFIX 0x20000 /* TC action piece */ struct tcamsg {- unsigned char tca_family;- unsigned char tca__pad1;- unsigned short tca__pad2;+ unsigned char tca_family;+ unsigned char tca__pad1;+ unsigned short tca__pad2; }; #define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg)))) #define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))-#define TCA_ACT_TAB 1 /* attr type must be >=1 */ +#define TCA_ACT_TAB 1 /* attr type must be >=1 */ #define TCAA_MAX 1 /* End of information exported to user level */ - #endif /* __LINUX_RTNETLINK_H */diff -uNr iproute2/include/linux/shim.h iproute2-mpls/include/linux/shim.h--- iproute2/include/linux/shim.h 1969-12-31 18:00:00.000000000 -0600+++ iproute2-mpls/include/linux/shim.h 2005-12-08 22:01:52.000000000 -0600@@ -0,0 +1,12 @@+#ifndef LINUX_SHIM_H+#define LINUX_SHIM_H++#define SHIMNAMSIZ 16+struct rtshim+{+ char name[SHIMNAMSIZ+1];+ short datalen;+ char data[0];+};++#endifdiff -uNr iproute2/include/utils.h iproute2-mpls/include/utils.h--- iproute2/include/utils.h 2005-08-24 00:23:21.000000000 -0500+++ iproute2-mpls/include/utils.h 2005-12-08 22:01:52.000000000 -0600@@ -64,6 +64,11 @@ u_int8_t ipx_node[IPX_NODE_LEN]; }; +#ifndef AF_MPLS+#define AF_MPLS 30+#define PF_MPLS AF_MPLS+#endif+ extern __u32 get_addr32(const char *name); extern int get_addr_1(inet_prefix *dst, const char *arg, int family); extern int get_prefix_1(inet_prefix *dst, char *arg, int family);diff -uNr iproute2/ip/iproute.c iproute2-mpls/ip/iproute.c--- iproute2/ip/iproute.c 2005-08-24 00:23:21.000000000 -0500+++ iproute2-mpls/ip/iproute.c 2005-12-08 22:01:52.000000000 -0600@@ -28,6 +28,7 @@ #include <netinet/ip.h> #include <arpa/inet.h> #include <linux/in_route.h>+#include <linux/shim.h> #include "rt_names.h" #include "utils.h"@@ -54,7 +55,8 @@ fprintf(stderr, " [ table TABLE_ID ] [ proto RTPROTO ]\n"); fprintf(stderr, " [ scope SCOPE ] [ metric METRIC ]\n"); fprintf(stderr, "INFO_SPEC := NH OPTIONS FLAGS [ nexthop NH ]...\n");- fprintf(stderr, "NH := [ via ADDRESS ] [ dev STRING ] [ weight NUMBER ] NHFLAGS\n");+ fprintf(stderr, "NH := [ via ADDRESS ] [ dev STRING ] [ weight NUMBER ]\n");+ fprintf(stderr, " [ shim STRING STRING ] [ mpls NUMBER ] NHFLAGS\n"); fprintf(stderr, "OPTIONS := FLAGS [ mtu NUMBER ] [ advmss NUMBER ]\n"); fprintf(stderr, " [ rtt NUMBER ] [ rttvar NUMBER ]\n"); fprintf(stderr, " [ window NUMBER] [ cwnd NUMBER ] [ ssthresh NUMBER ]\n");@@ -91,6 +93,8 @@ inet_prefix mdst; inet_prefix rsrc; inet_prefix msrc;+ unsigned int mpls;+ char *shim_name; } filter; static int flush_update(void)@@ -252,6 +256,19 @@ if ((oif^filter.oif)&filter.oifmask) return 0; }+ if (filter.mpls) {+ struct rtshim *shim = NULL;+ if (tb[RTA_SHIM])+ shim = RTA_DATA(tb[RTA_SHIM]);+ if (shim && !memcmp(&filter.mpls, shim->data, shim->datalen)) + return 0;+ } else if (filter.shim_name) {+ struct rtshim *shim = NULL;+ if (tb[RTA_SHIM])+ shim = RTA_DATA(tb[RTA_SHIM]);+ if (shim && !strncmp(filter.shim_name, shim->name, SHIMNAMSIZ))+ return 0;+ } if (filter.flushb && r->rtm_family == AF_INET6 && r->rtm_dst_len == 0 &&@@ -259,7 +276,6 @@ tb[RTA_PRIORITY] && *(int*)RTA_DATA(tb[RTA_PRIORITY]) == -1) return 0;- if (filter.flushb) { struct nlmsghdr *fn; if (NLMSG_ALIGN(filter.flushp) + n->nlmsg_len > filter.flushe) {@@ -333,6 +349,22 @@ } if (tb[RTA_OIF] && filter.oifmask != -1) fprintf(fp, "dev %s ", ll_index_to_name(*(int*)RTA_DATA(tb[RTA_OIF])));+ if (tb[RTA_SHIM]) {+ struct rtshim *shim;++ shim = RTA_DATA(tb[RTA_SHIM]);+ if (!strncmp("mpls", shim->name, 4)) {+ unsigned int key;+ memcpy(&key, shim->data, 4);+ fprintf(fp, "mpls 0x%x", key);+ } else {+ int i;+ fprintf(fp, "shim %s 0x", shim->name);+ for (i = 0;i < shim->datalen;i++) {+ fprintf(fp, "%02x", shim->data[i]);+ }+ }+ } if (!(r->rtm_flags&RTM_F_CLONED)) { if (r->rtm_table != RT_TABLE_MAIN && !filter.tb)@@ -562,6 +594,39 @@ return 0; } +#define SHIM_MAXSIZE 256+int parse_shim(struct rtshim *shim, char *name, char *data)+{+ char str[(SHIM_MAXSIZE * 2) + 1];+ int datalen = 0;+ char hex[3];+ int i, slen;++ strncpy(shim->name, name, SHIMNAMSIZ);++ if (strncmp(data, "0x", 2))+ invarg("\"shim data\" value is invalid\n", data);++ slen = strlen(data);+ if (slen > ((SHIM_MAXSIZE * 2) + 2))+ invarg("\"shim data\" value is too long\n", data);++ if (slen & 1) {+ str[0] = '0';+ strcpy(&str[1], &data[2]);+ } else {+ strcpy(str, &data[2]);+ }++ slen = strlen(str);+ for (i = 0;i < slen;i += 2) {+ strncpy(hex, &str[i], 2);+ shim->data[datalen++] = strtoul(hex, NULL, 16);+ }+ shim->datalen = datalen;++ return datalen;+} int parse_one_nh(struct rtattr *rta, struct rtnexthop *rtnh, int *argcp, char ***argvp) {@@ -587,6 +652,41 @@ rtnh->rtnh_hops = w - 1; } else if (strcmp(*argv, "onlink") == 0) { rtnh->rtnh_flags |= RTNH_F_ONLINK;+ } else if (strcmp(*argv, "mpls") == 0) {+ char buf[sizeof(struct rtshim) + sizeof(unsigned int)];+ struct rtshim *shim = (struct rtshim *)buf;+ unsigned int key;++ NEXT_ARG();+ if (get_unsigned(&key, *argv, 0))+ invarg("\"mpls key\" is invalid\n", *argv);++ strcpy(shim->name, "mpls");+ memcpy(shim->data, &key, sizeof(unsigned int));+ shim->datalen = sizeof(unsigned int);++ rta_addattr_l(rta, 4096, RTA_SHIM, shim,+ sizeof(struct rtshim) + sizeof(unsigned int));+ rtnh->rtnh_len += sizeof(struct rtattr) ++ sizeof(struct rtshim) + sizeof(unsigned int);+ } else if (strcmp(*argv, "shim") == 0) {+ char buf[sizeof(struct rtshim) + SHIM_MAXSIZE];+ struct rtshim *shim = (struct rtshim *)buf;+ int datalen;+ char *name;+ char *data;++ NEXT_ARG();+ name = *argv;+ NEXT_ARG();+ data = *argv;++ datalen = parse_shim(shim, name, data);++ rta_addattr_l(rta, 4096, RTA_SHIM, shim,+ sizeof(struct rtshim) + datalen);+ rtnh->rtnh_len += sizeof(struct rtattr) ++ sizeof(struct rtshim) + datalen; } else break; }@@ -684,6 +784,37 @@ if (req.r.rtm_family == AF_UNSPEC) req.r.rtm_family = addr.family; addattr_l(&req.n, sizeof(req), RTA_GATEWAY, &addr.data, addr.bytelen);+ } else if (strcmp(*argv, "mpls") == 0) {+ char buf[sizeof(struct rtshim) + sizeof(unsigned int)];+ struct rtshim *shim = (struct rtshim *)buf;+ unsigned int key;++ NEXT_ARG();+ if (get_unsigned(&key, *argv, 0))+ invarg("\"mpls key\" is invalid\n", *argv);++ strcpy(shim->name, "mpls");+ memcpy(shim->data, &key, sizeof(unsigned int));+ shim->datalen = sizeof(unsigned int);++ addattr_l(&req.n, sizeof(req), RTA_SHIM, shim,+ sizeof(struct rtshim) + sizeof(unsigned int));+ } else if (strcmp(*argv, "shim") == 0) {+ char buf[sizeof(struct rtshim) + SHIM_MAXSIZE];+ struct rtshim *shim = (struct rtshim *)buf;+ int datalen;+ char *name;+ char *data;++ NEXT_ARG();+ name = *argv;+ NEXT_ARG();+ data = *argv;++ datalen = parse_shim(shim, name, data);++ addattr_l(&req.n, sizeof(req), RTA_SHIM, shim,+ sizeof(struct rtshim) + datalen); } else if (strcmp(*argv, "from") == 0) { inet_prefix addr; NEXT_ARG();@@ -1050,6 +1181,15 @@ } else if (strcmp(*argv, "src") == 0) { NEXT_ARG(); get_prefix(&filter.rprefsrc, *argv, do_ipv6);+ } else if (matches(*argv, "mpls") == 0) {+ unsigned int key;+ NEXT_ARG();+ if (get_unsigned(&key, *argv, 0))+ invarg("\"mpls key\" is invalid\n", *argv);+ filter.mpls = key;+ } else if (matches(*argv, "shim") == 0) {+ NEXT_ARG();+ filter.shim_name = *argv; } else if (matches(*argv, "realms") == 0) { __u32 realm; NEXT_ARG();@@ -1262,6 +1402,38 @@ strcmp(*argv, "dev") == 0) { NEXT_ARG(); odev = *argv;+ } else if (matches(*argv, "mpls") == 0) {+ char buf[sizeof(struct rtshim) + sizeof(unsigned int)];+ struct rtshim *shim = (struct rtshim *)buf;+ unsigned int key;++ NEXT_ARG();+ if (get_unsigned(&key, *argv, 0))+ invarg("\"mpls key\" is invalid\n", *argv);++ strcpy(shim->name, "mpls");+ memcpy(shim->data, &key, sizeof(unsigned int));+ shim->datalen = sizeof(unsigned int);++ addattr_l(&req.n, sizeof(req), RTA_SHIM, shim,+ sizeof(struct rtshim) + sizeof(unsigned int));+ } else if (matches(*argv, "shim") == 0) {+ char buf[sizeof(struct rtshim) + SHIM_MAXSIZE];+ struct rtshim *shim = (struct rtshim *)buf;+ int datalen;+ char *name;+ char *data;++ NEXT_ARG();+ name = *argv;+ NEXT_ARG();+ data = *argv;++ datalen = parse_shim(shim, name, data);++ addattr_l(&req.n, sizeof(req), RTA_SHIM, shim,+ sizeof(struct rtshim) + datalen);+ } else if (matches(*argv, "notify") == 0) { req.r.rtm_flags |= RTM_F_NOTIFY; } else if (matches(*argv, "connected") == 0) {@@ -1349,6 +1521,8 @@ } if (!odev && tb[RTA_OIF]) tb[RTA_OIF]->rta_type = 0;+ if (tb[RTA_SHIM])+ tb[RTA_SHIM]->rta_type = 0; if (tb[RTA_GATEWAY]) tb[RTA_GATEWAY]->rta_type = 0; if (!idev && tb[RTA_IIF])@@ -1413,4 +1587,3 @@ fprintf(stderr, "Command \"%s\" is unknown, try \"ip route help\".\n", *argv); exit(-1); }-diff -uNr iproute2/Makefile iproute2-mpls/Makefile--- iproute2/Makefile 2005-08-24 00:23:21.000000000 -0500+++ iproute2-mpls/Makefile 2005-12-08 22:01:51.000000000 -0600@@ -27,7 +27,7 @@ LDLIBS += -L../lib -lnetlink -lutil -SUBDIRS=lib ip tc misc netem
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -