1 diff -urN iproute2.old/ip/ipaddress.c iproute2/ip/ipaddress.c
2 --- iproute2.old/ip/ipaddress.c Sun Sep 10 21:03:26 2000
3 +++ iproute2/ip/ipaddress.c Thu Aug 23 06:07:46 2001
5 filter.oneline = oneline;
8 +int default_scope(inet_prefix *lcl)
10 + if (lcl->family == AF_INET) {
11 + if (lcl->bytelen >= 1 && *(__u8*)&lcl->data == 127)
12 + return RT_SCOPE_HOST;
17 int ipaddr_modify(int cmd, int argc, char **argv)
19 struct rtnl_handle rth;
26 memset(&req, 0, sizeof(req));
29 if (rtnl_rtscope_a2n(&scope, *argv))
30 invarg(*argv, "invalid scope value.");
31 req.ifa.ifa_scope = scope;
33 } else if (strcmp(*argv, "dev") == 0) {
37 brd_len = brd.bytelen;
40 + if (!scoped && cmd != RTM_DELADDR)
41 + req.ifa.ifa_scope = default_scope(&lcl);
43 if (rtnl_open(&rth, 0) < 0)
45 diff -urN iproute2.old/ip/ipmaddr.c iproute2/ip/ipmaddr.c
46 --- iproute2.old/ip/ipmaddr.c Sun Apr 16 19:42:51 2000
47 +++ iproute2/ip/ipmaddr.c Mon Dec 24 23:33:02 2001
50 static void print_maddr(FILE *fp, struct ma_info *list)
52 - fprintf(fp, "%s\t", _SL_);
55 if (list->addr.family == AF_PACKET) {
59 for (; list; list = list->next) {
61 - fprintf(fp, "%d:\t%s", cur_index, list->name);
62 + cur_index = list->index;
63 + fprintf(fp, "%d:\t%s%s", cur_index, list->name, _SL_);
64 } else if (cur_index != list->index) {
65 cur_index = list->index;
66 fprintf(fp, "%d:\t%s\n", cur_index, list->name);
67 diff -urN iproute2.old/ip/ipmroute.c iproute2/ip/ipmroute.c
68 --- iproute2.old/ip/ipmroute.c Sun Apr 16 19:42:51 2000
69 +++ iproute2/ip/ipmroute.c Mon Dec 24 22:38:55 2001
71 if (filter.msrc.family && inet_addr_match(&msrc, &filter.msrc, filter.msrc.bitlen))
74 - format_host(AF_INET, 4, &msrc.data[0], sbuf, sizeof(sbuf));
75 - format_host(AF_INET, 4, &maddr.data[0], mbuf, sizeof(mbuf));
76 - snprintf(obuf, sizeof(obuf), "(%s, %s)", sbuf, mbuf);
77 + snprintf(obuf, sizeof(obuf), "(%s, %s)",
78 + format_host(AF_INET, 4, &msrc.data[0], sbuf, sizeof(sbuf)),
79 + format_host(AF_INET, 4, &maddr.data[0], mbuf, sizeof(mbuf)));
81 fprintf(ofp, "%-32s Iif: ", obuf);
85 if (strcmp(*argv, "iif") == 0) {
87 - strcpy(filter_dev, *argv);
88 + strncpy(filter_dev, *argv, sizeof(filter_dev)-1);
89 } else if (matches(*argv, "from") == 0) {
91 get_prefix(&filter.msrc, *argv, AF_INET);
92 diff -urN iproute2.old/ip/iproute.c iproute2/ip/iproute.c
93 --- iproute2.old/ip/iproute.c Thu Aug 2 06:32:09 2001
94 +++ iproute2/ip/iproute.c Thu Jan 10 03:12:16 2002
96 fprintf(stderr, "Error: unexpected end of line after \"nexthop\"\n");
99 + memset(rtnh, 0, sizeof(*rtnh));
100 rtnh->rtnh_len = sizeof(*rtnh);
101 - rtnh->rtnh_ifindex = 0;
102 rta->rta_len += rtnh->rtnh_len;
103 parse_one_nh(rta, rtnh, &argc, &argv);
104 rtnh = RTNH_NEXT(rtnh);
105 diff -urN iproute2.old/ip/iptunnel.c iproute2/ip/iptunnel.c
106 --- iproute2.old/ip/iptunnel.c Sun Apr 16 19:42:51 2000
107 +++ iproute2/ip/iptunnel.c Mon Dec 24 22:29:41 2001
108 @@ -399,31 +399,36 @@
110 void print_tunnel(struct ip_tunnel_parm *p)
119 - format_host(AF_INET, 4, &p->iph.daddr, s1, sizeof(s1));
120 - format_host(AF_INET, 4, &p->iph.saddr, s2, sizeof(s2));
121 inet_ntop(AF_INET, &p->i_key, s3, sizeof(s3));
122 inet_ntop(AF_INET, &p->o_key, s4, sizeof(s4));
124 + /* Do not use format_host() for local addr,
125 + * symbolic name will not be useful.
127 printf("%s: %s/ip remote %s local %s ",
129 p->iph.protocol == IPPROTO_IPIP ? "ip" :
130 (p->iph.protocol == IPPROTO_GRE ? "gre" :
131 (p->iph.protocol == IPPROTO_IPV6 ? "ipv6" : "unknown")),
132 - p->iph.daddr ? s1 : "any", p->iph.saddr ? s2 : "any");
133 + p->iph.daddr ? format_host(AF_INET, 4, &p->iph.daddr, s1, sizeof(s1)) : "any",
134 + p->iph.saddr ? rt_addr_n2a(AF_INET, 4, &p->iph.saddr, s2, sizeof(s2)) : "any");
137 char *n = do_ioctl_get_ifname(p->link);
139 printf(" dev %s ", n);
143 printf(" ttl %d ", p->iph.ttl);
145 printf(" ttl inherit ");
151 printf("%c%s ", p->iph.tos&1 ? '/' : ' ',
152 rtnl_dsfield_n2a(p->iph.tos&~1, b1, sizeof(b1)));
155 if (!(p->iph.frag_off&htons(IP_DF)))
156 printf(" nopmtudisc");
158 diff -urN iproute2.old/lib/libnetlink.c iproute2/lib/libnetlink.c
159 --- iproute2.old/lib/libnetlink.c Fri Aug 3 00:43:41 2001
160 +++ iproute2/lib/libnetlink.c Fri Aug 24 21:32:05 2001
165 + iov.iov_len = sizeof(buf);
166 status = recvmsg(rtnl->fd, &msg, 0);
169 diff -urN iproute2.old/lib/utils.c iproute2/lib/utils.c
170 --- iproute2.old/lib/utils.c Thu Aug 2 05:32:44 2001
171 +++ iproute2/lib/utils.c Thu Jan 10 03:33:53 2002
174 memset(dst, 0, sizeof(*dst));
176 - if (strcmp(arg, "default") == 0 || strcmp(arg, "any") == 0) {
177 + if (strcmp(arg, "default") == 0 ||
178 + strcmp(arg, "any") == 0 ||
179 + strcmp(arg, "all") == 0) {
180 if (family == AF_DECnet)
182 dst->family = family;
189 - FILE *fp = fopen("/proc/net/psched", "r");
193 + return atoi(getenv("HZ")) ? : HZ;
195 + if (getenv("PROC_NET_PSCHED")) {
196 + snprintf(name, sizeof(name)-1, "%s", getenv("PROC_NET_PSCHED"));
197 + } else if (getenv("PROC_ROOT")) {
198 + snprintf(name, sizeof(name)-1, "%s/net/psched", getenv("PROC_ROOT"));
200 + strcpy(name, "/proc/net/psched");
202 + fp = fopen(name, "r");