From 738aebe52b2e53b45bb0e8b55fe341fdb25ff994 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 11 Dec 2018 08:40:09 -0800 Subject: [PATCH] drop support for DECnet DECnet belongs in the history museum of dead protocols along with Appletalk and IPX. Linux support has outlived its natural life and the time has come to remove it from iproute2. Dead code is a source of bugs and exploits. If anyone actually has DECnet running on some old distribution they can just keep to the old version of iproute2. Signed-off-by: Stephen Hemminger Signed-off-by: David Ahern --- Makefile | 3 -- README.decnet | 33 -------------- README.lnstat | 2 +- include/utils.h | 3 -- ip/ip.c | 2 +- ip/iproute.c | 2 +- lib/dnet_ntop.c | 101 ----------------------------------------- lib/dnet_pton.c | 75 ------------------------------ lib/utils.c | 23 ---------- man/man8/ip-route.8.in | 2 +- man/man8/ip.8 | 9 +--- 11 files changed, 6 insertions(+), 249 deletions(-) delete mode 100644 README.decnet delete mode 100644 lib/dnet_ntop.c delete mode 100644 lib/dnet_pton.c diff --git a/Makefile b/Makefile index 7d62468c..ad96fd54 100644 --- a/Makefile +++ b/Makefile @@ -40,9 +40,6 @@ DEFINES+=-DCONFDIR=\"$(CONFDIR)\" \ -DNETNS_RUN_DIR=\"$(NETNS_RUN_DIR)\" \ -DNETNS_ETC_DIR=\"$(NETNS_ETC_DIR)\" -#options for decnet -ADDLIB+=dnet_ntop.o dnet_pton.o - #options for mpls ADDLIB+=mpls_ntop.o mpls_pton.o diff --git a/README.decnet b/README.decnet deleted file mode 100644 index 4300f906..00000000 --- a/README.decnet +++ /dev/null @@ -1,33 +0,0 @@ - -Here are a few quick points about DECnet support... - - o iproute2 is the tool of choice for configuring the DECnet support for - Linux. For many features, it is the only tool which can be used to - configure them. - - o No name resolution is available as yet, all addresses must be - entered numerically. - - o Remember to set the hardware address of the interface using: - - ip link set ethX address xx:xx:xx:xx:xx:xx - (where xx:xx:xx:xx:xx:xx is the MAC address for your DECnet node - address) - - if your Ethernet card won't listen to more than one unicast - mac address at once. If the Linux DECnet stack doesn't talk to - any other DECnet nodes, then check this with tcpdump and if its - a problem, change the mac address (but do this _before_ starting - any other network protocol on the interface) - - o Whilst you can use ip addr add to add more than one DECnet address to an - interface, don't expect addresses which are not the same as the - kernels node address to work properly with 2.4 kernels. This should - be fine with 2.6 kernels as the routing code has been extensively - modified and improved. - - o The DECnet support is currently self contained. It does not depend on - the libdnet library. - -Steve Whitehouse - diff --git a/README.lnstat b/README.lnstat index 057925f6..59134a15 100644 --- a/README.lnstat +++ b/README.lnstat @@ -9,7 +9,7 @@ In addition to routing cache statistics, it supports any kind of statistics the linux kernel exports via a file in /proc/net/stat. In a stock 2.6.9 kernel, this is per-protocol neighbour cache statistics - (ipv4, ipv6, atm, decnet) + (ipv4, ipv6, atm) routing cache statistics (ipv4) connection tracking statistics diff --git a/include/utils.h b/include/utils.h index fee7ff28..92bbe82d 100644 --- a/include/utils.h +++ b/include/utils.h @@ -194,9 +194,6 @@ int matches(const char *arg, const char *pattern); int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits); int inet_addr_match_rta(const inet_prefix *m, const struct rtattr *rta); -const char *dnet_ntop(int af, const void *addr, char *str, size_t len); -int dnet_pton(int af, const char *src, void *addr); - const char *mpls_ntop(int af, const void *addr, char *str, size_t len); int mpls_pton(int af, const char *src, void *addr, size_t alen); diff --git a/ip/ip.c b/ip/ip.c index 11dbed72..a5bbacb4 100644 --- a/ip/ip.c +++ b/ip/ip.c @@ -53,7 +53,7 @@ static void usage(void) " vrf | sr }\n" " OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n" " -h[uman-readable] | -iec | -j[son] | -p[retty] |\n" -" -f[amily] { inet | inet6 | dnet | mpls | bridge | link } |\n" +" -f[amily] { inet | inet6 | mpls | bridge | link } |\n" " -4 | -6 | -I | -D | -M | -B | -0 |\n" " -l[oops] { maximum-addr-flush-attempts } | -br[ief] |\n" " -o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] |\n" diff --git a/ip/iproute.c b/ip/iproute.c index 26f7cd89..60e46e03 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -83,7 +83,7 @@ static void usage(void) "INFO_SPEC := NH OPTIONS FLAGS [ nexthop NH ]...\n" "NH := [ encap ENCAPTYPE ENCAPHDR ] [ via [ FAMILY ] ADDRESS ]\n" " [ dev STRING ] [ weight NUMBER ] NHFLAGS\n" - "FAMILY := [ inet | inet6 | dnet | mpls | bridge | link ]\n" + "FAMILY := [ inet | inet6 | mpls | bridge | link ]\n" "OPTIONS := FLAGS [ mtu NUMBER ] [ advmss NUMBER ] [ as [ to ] ADDRESS ]\n" " [ rtt TIME ] [ rttvar TIME ] [ reordering NUMBER ]\n" " [ window NUMBER ] [ cwnd NUMBER ] [ initcwnd NUMBER ]\n" diff --git a/lib/dnet_ntop.c b/lib/dnet_ntop.c deleted file mode 100644 index 17d960e3..00000000 --- a/lib/dnet_ntop.c +++ /dev/null @@ -1,101 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include -#include -#include -#include - -#include "utils.h" - -static __inline__ u_int16_t dn_ntohs(u_int16_t addr) -{ - union { - u_int8_t byte[2]; - u_int16_t word; - } u; - - u.word = addr; - return ((u_int16_t)u.byte[0]) | (((u_int16_t)u.byte[1]) << 8); -} - -static __inline__ int do_digit(char *str, u_int16_t *addr, u_int16_t scale, size_t *pos, size_t len, int *started) -{ - u_int16_t tmp = *addr / scale; - - if (*pos == len) - return 1; - - if (((tmp) > 0) || *started || (scale == 1)) { - *str = tmp + '0'; - *started = 1; - (*pos)++; - *addr -= (tmp * scale); - } - - return 0; -} - - -static const char *dnet_ntop1(const struct dn_naddr *dna, char *str, size_t len) -{ - u_int16_t addr, area; - size_t pos = 0; - int started = 0; - - memcpy(&addr, dna->a_addr, sizeof(addr)); - addr = dn_ntohs(addr); - area = addr >> 10; - - if (dna->a_len != 2) - return NULL; - - addr &= 0x03ff; - - if (len == 0) - return str; - - if (do_digit(str + pos, &area, 10, &pos, len, &started)) - return str; - - if (do_digit(str + pos, &area, 1, &pos, len, &started)) - return str; - - if (pos == len) - return str; - - *(str + pos) = '.'; - pos++; - started = 0; - - if (do_digit(str + pos, &addr, 1000, &pos, len, &started)) - return str; - - if (do_digit(str + pos, &addr, 100, &pos, len, &started)) - return str; - - if (do_digit(str + pos, &addr, 10, &pos, len, &started)) - return str; - - if (do_digit(str + pos, &addr, 1, &pos, len, &started)) - return str; - - if (pos == len) - return str; - - *(str + pos) = 0; - - return str; -} - - -const char *dnet_ntop(int af, const void *addr, char *str, size_t len) -{ - switch(af) { - case AF_DECnet: - errno = 0; - return dnet_ntop1((struct dn_naddr *)addr, str, len); - default: - errno = EAFNOSUPPORT; - } - - return NULL; -} diff --git a/lib/dnet_pton.c b/lib/dnet_pton.c deleted file mode 100644 index 1cf54e51..00000000 --- a/lib/dnet_pton.c +++ /dev/null @@ -1,75 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include -#include -#include -#include - -#include "utils.h" - -static __inline__ u_int16_t dn_htons(u_int16_t addr) -{ - union { - u_int8_t byte[2]; - u_int16_t word; - } u; - - u.word = addr; - return ((u_int16_t)u.byte[0]) | (((u_int16_t)u.byte[1]) << 8); -} - - -static int dnet_num(const char *src, u_int16_t * dst) -{ - int rv = 0; - int tmp; - *dst = 0; - - while ((tmp = *src++) != 0) { - tmp -= '0'; - if ((tmp < 0) || (tmp > 9)) - return rv; - - rv++; - (*dst) *= 10; - (*dst) += tmp; - } - - return rv; -} - -static int dnet_pton1(const char *src, struct dn_naddr *dna) -{ - u_int16_t addr; - u_int16_t area = 0; - u_int16_t node = 0; - int pos; - - pos = dnet_num(src, &area); - if ((pos == 0) || (area > 63) || (*(src + pos) != '.')) - return 0; - pos = dnet_num(src + pos + 1, &node); - if ((pos == 0) || (node > 1023)) - return 0; - dna->a_len = 2; - addr = dn_htons((area << 10) | node); - memcpy(dna->a_addr, &addr, sizeof(addr)); - - return 1; -} - -int dnet_pton(int af, const char *src, void *addr) -{ - int err; - - switch (af) { - case AF_DECnet: - errno = 0; - err = dnet_pton1(src, (struct dn_naddr *)addr); - break; - default: - errno = EAFNOSUPPORT; - err = -1; - } - - return err; -} diff --git a/lib/utils.c b/lib/utils.c index 22bc6c8d..9ebc8274 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -600,18 +600,6 @@ static int __get_addr_1(inet_prefix *addr, const char *name, int family) return 0; } - if (family == AF_DECnet) { - struct dn_naddr dna; - - addr->family = AF_DECnet; - if (dnet_pton(AF_DECnet, name, &dna) <= 0) - return -1; - memcpy(addr->data, dna.a_addr, 2); - addr->bytelen = 2; - addr->bitlen = -1; - return 0; - } - if (family == AF_MPLS) { unsigned int maxlabels; int i; @@ -1000,13 +988,6 @@ const char *rt_addr_n2a_r(int af, int len, return inet_ntop(af, addr, buf, buflen); case AF_MPLS: return mpls_ntop(af, addr, buf, buflen); - case AF_DECnet: - { - struct dn_naddr dna = { 2, { 0, 0, } }; - - memcpy(dna.a_addr, addr, 2); - return dnet_ntop(af, &dna, buf, buflen); - } case AF_PACKET: return ll_addr_n2a(addr, len, ARPHRD_VOID, buf, buflen); case AF_BRIDGE: @@ -1048,8 +1029,6 @@ int read_family(const char *name) family = AF_INET; else if (strcmp(name, "inet6") == 0) family = AF_INET6; - else if (strcmp(name, "dnet") == 0) - family = AF_DECnet; else if (strcmp(name, "link") == 0) family = AF_PACKET; else if (strcmp(name, "ipx") == 0) @@ -1067,8 +1046,6 @@ const char *family_name(int family) return "inet"; if (family == AF_INET6) return "inet6"; - if (family == AF_DECnet) - return "dnet"; if (family == AF_PACKET) return "link"; if (family == AF_IPX) diff --git a/man/man8/ip-route.8.in b/man/man8/ip-route.8.in index a664d848..9603ac6e 100644 --- a/man/man8/ip-route.8.in +++ b/man/man8/ip-route.8.in @@ -107,7 +107,7 @@ replace " } " .ti -8 .IR FAMILY " := [ " -.BR inet " | " inet6 " | " dnet " | " mpls " | " bridge " | " link " ]" +.BR inet " | " inet6 " | " mpls " | " bridge " | " link " ]" .ti -8 .IR OPTIONS " := " FLAGS " [ " diff --git a/man/man8/ip.8 b/man/man8/ip.8 index 16867efb..84ade110 100644 --- a/man/man8/ip.8 +++ b/man/man8/ip.8 @@ -34,7 +34,7 @@ ip \- show / manipulate routing, network devices, interfaces and tunnels \fB\-r\fR[\fIesolve\fR] | \fB\-iec\fR | \fB\-f\fR[\fIamily\fR] { -.BR inet " | " inet6 " | " dnet " | " link " } | " +.BR inet " | " inet6 " | " link " } | " \fB-4\fR | \fB-6\fR | \fB-I\fR | @@ -94,7 +94,7 @@ Zero (0) means loop until all addresses are removed. .TP .BR "\-f" , " \-family " Specifies the protocol family to use. The protocol family identifier can be one of -.BR "inet" , " inet6" , " bridge" , " dnet" , " mpls" +.BR "inet" , " inet6" , " bridge" , " mpls" or .BR link . If this option is not present, @@ -125,11 +125,6 @@ shortcut for shortcut for .BR "\-family bridge" . -.TP -.B \-D -shortcut for -.BR "\-family decnet" . - .TP .B \-M shortcut for -- 2.39.2