Merge lp:~logan/ubuntu/raring/iproute/debian-merge into lp:ubuntu/raring/iproute
- Raring (13.04)
- debian-merge
- Merge into raring
Proposed by
Logan Rosen
Status: | Merged |
---|---|
Merged at revision: | 40 |
Proposed branch: | lp:~logan/ubuntu/raring/iproute/debian-merge |
Merge into: | lp:ubuntu/raring/iproute |
Diff against target: |
1683 lines (+115/-1506) 8 files modified
.pc/7f747fd9377b8538adeba7332d25905ba08ac156.diff/ip/ipaddress.c (+0/-1416) .pc/applied-patches (+1/-1) debian/changelog (+25/-0) debian/control (+1/-1) debian/patches/0001-iproute2-List-interfaces-without-net-address-by-defa.patch (+86/-0) debian/patches/7f747fd9377b8538adeba7332d25905ba08ac156.diff (+0/-86) debian/patches/series (+1/-1) debian/rules (+1/-1) |
To merge this branch: | bzr merge lp:~logan/ubuntu/raring/iproute/debian-merge |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Holbach (community) | Approve | ||
Ubuntu branches | Pending | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed directory '.pc/7f747fd9377b8538adeba7332d25905ba08ac156.diff' |
2 | === removed directory '.pc/7f747fd9377b8538adeba7332d25905ba08ac156.diff/ip' |
3 | === removed file '.pc/7f747fd9377b8538adeba7332d25905ba08ac156.diff/ip/ipaddress.c' |
4 | --- .pc/7f747fd9377b8538adeba7332d25905ba08ac156.diff/ip/ipaddress.c 2012-11-09 15:10:54 +0000 |
5 | +++ .pc/7f747fd9377b8538adeba7332d25905ba08ac156.diff/ip/ipaddress.c 1970-01-01 00:00:00 +0000 |
6 | @@ -1,1416 +0,0 @@ |
7 | -/* |
8 | - * ipaddress.c "ip address". |
9 | - * |
10 | - * This program is free software; you can redistribute it and/or |
11 | - * modify it under the terms of the GNU General Public License |
12 | - * as published by the Free Software Foundation; either version |
13 | - * 2 of the License, or (at your option) any later version. |
14 | - * |
15 | - * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
16 | - * |
17 | - */ |
18 | - |
19 | -#include <stdio.h> |
20 | -#include <stdlib.h> |
21 | -#include <unistd.h> |
22 | -#include <syslog.h> |
23 | -#include <inttypes.h> |
24 | -#include <fcntl.h> |
25 | -#include <sys/ioctl.h> |
26 | -#include <sys/socket.h> |
27 | -#include <sys/ioctl.h> |
28 | -#include <sys/errno.h> |
29 | -#include <netinet/in.h> |
30 | -#include <arpa/inet.h> |
31 | -#include <string.h> |
32 | -#include <fnmatch.h> |
33 | - |
34 | -#include <linux/netdevice.h> |
35 | -#include <linux/if_arp.h> |
36 | -#include <linux/sockios.h> |
37 | - |
38 | -#include "rt_names.h" |
39 | -#include "utils.h" |
40 | -#include "ll_map.h" |
41 | -#include "ip_common.h" |
42 | - |
43 | -enum { |
44 | - IPADD_LIST, |
45 | - IPADD_FLUSH, |
46 | - IPADD_SAVE, |
47 | -}; |
48 | - |
49 | -static struct |
50 | -{ |
51 | - int ifindex; |
52 | - int family; |
53 | - int oneline; |
54 | - int showqueue; |
55 | - inet_prefix pfx; |
56 | - int scope, scopemask; |
57 | - int flags, flagmask; |
58 | - int up; |
59 | - char *label; |
60 | - int flushed; |
61 | - char *flushb; |
62 | - int flushp; |
63 | - int flushe; |
64 | - int group; |
65 | -} filter; |
66 | - |
67 | -static int do_link; |
68 | - |
69 | -static void usage(void) __attribute__((noreturn)); |
70 | - |
71 | -static void usage(void) |
72 | -{ |
73 | - if (do_link) { |
74 | - iplink_usage(); |
75 | - } |
76 | - fprintf(stderr, "Usage: ip addr {add|change|replace} IFADDR dev STRING [ LIFETIME ]\n"); |
77 | - fprintf(stderr, " [ CONFFLAG-LIST ]\n"); |
78 | - fprintf(stderr, " ip addr del IFADDR dev STRING\n"); |
79 | - fprintf(stderr, " ip addr {show|save|flush} [ dev STRING ] [ scope SCOPE-ID ]\n"); |
80 | - fprintf(stderr, " [ to PREFIX ] [ FLAG-LIST ] [ label PATTERN ]\n"); |
81 | - fprintf(stderr, " ip addr {showdump|restore}\n"); |
82 | - fprintf(stderr, "IFADDR := PREFIX | ADDR peer PREFIX\n"); |
83 | - fprintf(stderr, " [ broadcast ADDR ] [ anycast ADDR ]\n"); |
84 | - fprintf(stderr, " [ label STRING ] [ scope SCOPE-ID ]\n"); |
85 | - fprintf(stderr, "SCOPE-ID := [ host | link | global | NUMBER ]\n"); |
86 | - fprintf(stderr, "FLAG-LIST := [ FLAG-LIST ] FLAG\n"); |
87 | - fprintf(stderr, "FLAG := [ permanent | dynamic | secondary | primary |\n"); |
88 | - fprintf(stderr, " tentative | deprecated | dadfailed | temporary |\n"); |
89 | - fprintf(stderr, " CONFFLAG-LIST ]\n"); |
90 | - fprintf(stderr, "CONFFLAG-LIST := [ CONFFLAG-LIST ] CONFFLAG\n"); |
91 | - fprintf(stderr, "CONFFLAG := [ home | nodad ]\n"); |
92 | - fprintf(stderr, "LIFETIME := [ valid_lft LFT ] [ preferred_lft LFT ]\n"); |
93 | - fprintf(stderr, "LFT := forever | SECONDS\n"); |
94 | - |
95 | - exit(-1); |
96 | -} |
97 | - |
98 | -void print_link_flags(FILE *fp, unsigned flags, unsigned mdown) |
99 | -{ |
100 | - fprintf(fp, "<"); |
101 | - if (flags & IFF_UP && !(flags & IFF_RUNNING)) |
102 | - fprintf(fp, "NO-CARRIER%s", flags ? "," : ""); |
103 | - flags &= ~IFF_RUNNING; |
104 | -#define _PF(f) if (flags&IFF_##f) { \ |
105 | - flags &= ~IFF_##f ; \ |
106 | - fprintf(fp, #f "%s", flags ? "," : ""); } |
107 | - _PF(LOOPBACK); |
108 | - _PF(BROADCAST); |
109 | - _PF(POINTOPOINT); |
110 | - _PF(MULTICAST); |
111 | - _PF(NOARP); |
112 | - _PF(ALLMULTI); |
113 | - _PF(PROMISC); |
114 | - _PF(MASTER); |
115 | - _PF(SLAVE); |
116 | - _PF(DEBUG); |
117 | - _PF(DYNAMIC); |
118 | - _PF(AUTOMEDIA); |
119 | - _PF(PORTSEL); |
120 | - _PF(NOTRAILERS); |
121 | - _PF(UP); |
122 | - _PF(LOWER_UP); |
123 | - _PF(DORMANT); |
124 | - _PF(ECHO); |
125 | -#undef _PF |
126 | - if (flags) |
127 | - fprintf(fp, "%x", flags); |
128 | - if (mdown) |
129 | - fprintf(fp, ",M-DOWN"); |
130 | - fprintf(fp, "> "); |
131 | -} |
132 | - |
133 | -static const char *oper_states[] = { |
134 | - "UNKNOWN", "NOTPRESENT", "DOWN", "LOWERLAYERDOWN", |
135 | - "TESTING", "DORMANT", "UP" |
136 | -}; |
137 | - |
138 | -static void print_operstate(FILE *f, __u8 state) |
139 | -{ |
140 | - if (state >= sizeof(oper_states)/sizeof(oper_states[0])) |
141 | - fprintf(f, "state %#x ", state); |
142 | - else |
143 | - fprintf(f, "state %s ", oper_states[state]); |
144 | -} |
145 | - |
146 | -int get_operstate(const char *name) |
147 | -{ |
148 | - int i; |
149 | - |
150 | - for (i = 0; i < sizeof(oper_states)/sizeof(oper_states[0]); i++) |
151 | - if (strcasecmp(name, oper_states[i]) == 0) |
152 | - return i; |
153 | - return -1; |
154 | -} |
155 | - |
156 | -static void print_queuelen(FILE *f, struct rtattr *tb[IFLA_MAX + 1]) |
157 | -{ |
158 | - int qlen; |
159 | - |
160 | - if (tb[IFLA_TXQLEN]) |
161 | - qlen = *(int *)RTA_DATA(tb[IFLA_TXQLEN]); |
162 | - else { |
163 | - struct ifreq ifr; |
164 | - int s = socket(AF_INET, SOCK_STREAM, 0); |
165 | - |
166 | - if (s < 0) |
167 | - return; |
168 | - |
169 | - memset(&ifr, 0, sizeof(ifr)); |
170 | - strcpy(ifr.ifr_name, rta_getattr_str(tb[IFLA_IFNAME])); |
171 | - if (ioctl(s, SIOCGIFTXQLEN, &ifr) < 0) { |
172 | - fprintf(f, "ioctl(SIOCGIFXQLEN) failed: %s\n", strerror(errno)); |
173 | - close(s); |
174 | - return; |
175 | - } |
176 | - close(s); |
177 | - qlen = ifr.ifr_qlen; |
178 | - } |
179 | - if (qlen) |
180 | - fprintf(f, "qlen %d", qlen); |
181 | -} |
182 | - |
183 | -static const char *link_modes[] = { |
184 | - "DEFAULT", "DORMANT" |
185 | -}; |
186 | - |
187 | -static void print_linkmode(FILE *f, struct rtattr *tb) |
188 | -{ |
189 | - unsigned int mode = rta_getattr_u8(tb); |
190 | - |
191 | - if (mode >= sizeof(link_modes) / sizeof(link_modes[0])) |
192 | - fprintf(f, "mode %d ", mode); |
193 | - else |
194 | - fprintf(f, "mode %s ", link_modes[mode]); |
195 | -} |
196 | - |
197 | -static void print_linktype(FILE *fp, struct rtattr *tb) |
198 | -{ |
199 | - struct rtattr *linkinfo[IFLA_INFO_MAX+1]; |
200 | - struct link_util *lu; |
201 | - char *kind; |
202 | - |
203 | - parse_rtattr_nested(linkinfo, IFLA_INFO_MAX, tb); |
204 | - |
205 | - if (!linkinfo[IFLA_INFO_KIND]) |
206 | - return; |
207 | - kind = RTA_DATA(linkinfo[IFLA_INFO_KIND]); |
208 | - |
209 | - fprintf(fp, "%s", _SL_); |
210 | - fprintf(fp, " %s ", kind); |
211 | - |
212 | - lu = get_link_kind(kind); |
213 | - if (!lu || !lu->print_opt) |
214 | - return; |
215 | - |
216 | - if (1) { |
217 | - struct rtattr *attr[lu->maxattr+1], **data = NULL; |
218 | - |
219 | - if (linkinfo[IFLA_INFO_DATA]) { |
220 | - parse_rtattr_nested(attr, lu->maxattr, |
221 | - linkinfo[IFLA_INFO_DATA]); |
222 | - data = attr; |
223 | - } |
224 | - lu->print_opt(lu, fp, data); |
225 | - |
226 | - if (linkinfo[IFLA_INFO_XSTATS] && show_stats && |
227 | - lu->print_xstats) |
228 | - lu->print_xstats(lu, fp, linkinfo[IFLA_INFO_XSTATS]); |
229 | - } |
230 | -} |
231 | - |
232 | -static void print_vfinfo(FILE *fp, struct rtattr *vfinfo) |
233 | -{ |
234 | - struct ifla_vf_mac *vf_mac; |
235 | - struct ifla_vf_vlan *vf_vlan; |
236 | - struct ifla_vf_tx_rate *vf_tx_rate; |
237 | - struct ifla_vf_spoofchk *vf_spoofchk; |
238 | - struct rtattr *vf[IFLA_VF_MAX+1]; |
239 | - struct rtattr *tmp; |
240 | - SPRINT_BUF(b1); |
241 | - |
242 | - if (vfinfo->rta_type != IFLA_VF_INFO) { |
243 | - fprintf(stderr, "BUG: rta type is %d\n", vfinfo->rta_type); |
244 | - return; |
245 | - } |
246 | - |
247 | - parse_rtattr_nested(vf, IFLA_VF_MAX, vfinfo); |
248 | - |
249 | - vf_mac = RTA_DATA(vf[IFLA_VF_MAC]); |
250 | - vf_vlan = RTA_DATA(vf[IFLA_VF_VLAN]); |
251 | - vf_tx_rate = RTA_DATA(vf[IFLA_VF_TX_RATE]); |
252 | - |
253 | - /* Check if the spoof checking vf info type is supported by |
254 | - * this kernel. |
255 | - */ |
256 | - tmp = (struct rtattr *)((char *)vf[IFLA_VF_TX_RATE] + |
257 | - vf[IFLA_VF_TX_RATE]->rta_len); |
258 | - |
259 | - if (tmp->rta_type != IFLA_VF_SPOOFCHK) |
260 | - vf_spoofchk = NULL; |
261 | - else |
262 | - vf_spoofchk = RTA_DATA(vf[IFLA_VF_SPOOFCHK]); |
263 | - |
264 | - fprintf(fp, "\n vf %d MAC %s", vf_mac->vf, |
265 | - ll_addr_n2a((unsigned char *)&vf_mac->mac, |
266 | - ETH_ALEN, 0, b1, sizeof(b1))); |
267 | - if (vf_vlan->vlan) |
268 | - fprintf(fp, ", vlan %d", vf_vlan->vlan); |
269 | - if (vf_vlan->qos) |
270 | - fprintf(fp, ", qos %d", vf_vlan->qos); |
271 | - if (vf_tx_rate->rate) |
272 | - fprintf(fp, ", tx rate %d (Mbps)", vf_tx_rate->rate); |
273 | - if (vf_spoofchk && vf_spoofchk->setting != -1) { |
274 | - if (vf_spoofchk->setting) |
275 | - fprintf(fp, ", spoof checking on"); |
276 | - else |
277 | - fprintf(fp, ", spoof checking off"); |
278 | - } |
279 | -} |
280 | - |
281 | -static void print_link_stats64(FILE *fp, const struct rtnl_link_stats64 *s) { |
282 | - fprintf(fp, "%s", _SL_); |
283 | - fprintf(fp, " RX: bytes packets errors dropped overrun mcast %s%s", |
284 | - s->rx_compressed ? "compressed" : "", _SL_); |
285 | - fprintf(fp, " %-10"PRIu64" %-8"PRIu64" %-7"PRIu64" %-7"PRIu64" %-7"PRIu64" %-7"PRIu64"", |
286 | - (uint64_t)s->rx_bytes, |
287 | - (uint64_t)s->rx_packets, |
288 | - (uint64_t)s->rx_errors, |
289 | - (uint64_t)s->rx_dropped, |
290 | - (uint64_t)s->rx_over_errors, |
291 | - (uint64_t)s->multicast); |
292 | - if (s->rx_compressed) |
293 | - fprintf(fp, " %-7"PRIu64"", |
294 | - (uint64_t)s->rx_compressed); |
295 | - if (show_stats > 1) { |
296 | - fprintf(fp, "%s", _SL_); |
297 | - fprintf(fp, " RX errors: length crc frame fifo missed%s", _SL_); |
298 | - fprintf(fp, " %-7"PRIu64" %-7"PRIu64" %-7"PRIu64" %-7"PRIu64" %-7"PRIu64"", |
299 | - (uint64_t)s->rx_length_errors, |
300 | - (uint64_t)s->rx_crc_errors, |
301 | - (uint64_t)s->rx_frame_errors, |
302 | - (uint64_t)s->rx_fifo_errors, |
303 | - (uint64_t)s->rx_missed_errors); |
304 | - } |
305 | - fprintf(fp, "%s", _SL_); |
306 | - fprintf(fp, " TX: bytes packets errors dropped carrier collsns %s%s", |
307 | - (uint64_t)s->tx_compressed ? "compressed" : "", _SL_); |
308 | - fprintf(fp, " %-10"PRIu64" %-8"PRIu64" %-7"PRIu64" %-7"PRIu64" %-7"PRIu64" %-7"PRIu64"", |
309 | - (uint64_t)s->tx_bytes, |
310 | - (uint64_t)s->tx_packets, |
311 | - (uint64_t)s->tx_errors, |
312 | - (uint64_t)s->tx_dropped, |
313 | - (uint64_t)s->tx_carrier_errors, |
314 | - (uint64_t)s->collisions); |
315 | - if (s->tx_compressed) |
316 | - fprintf(fp, " %-7"PRIu64"", |
317 | - (uint64_t)s->tx_compressed); |
318 | - if (show_stats > 1) { |
319 | - fprintf(fp, "%s", _SL_); |
320 | - fprintf(fp, " TX errors: aborted fifo window heartbeat%s", _SL_); |
321 | - fprintf(fp, " %-7"PRIu64" %-7"PRIu64" %-7"PRIu64" %-7"PRIu64"", |
322 | - (uint64_t)s->tx_aborted_errors, |
323 | - (uint64_t)s->tx_fifo_errors, |
324 | - (uint64_t)s->tx_window_errors, |
325 | - (uint64_t)s->tx_heartbeat_errors); |
326 | - } |
327 | -} |
328 | - |
329 | -static void print_link_stats(FILE *fp, const struct rtnl_link_stats *s) |
330 | -{ |
331 | - fprintf(fp, "%s", _SL_); |
332 | - fprintf(fp, " RX: bytes packets errors dropped overrun mcast %s%s", |
333 | - s->rx_compressed ? "compressed" : "", _SL_); |
334 | - fprintf(fp, " %-10u %-8u %-7u %-7u %-7u %-7u", |
335 | - s->rx_bytes, s->rx_packets, s->rx_errors, |
336 | - s->rx_dropped, s->rx_over_errors, |
337 | - s->multicast |
338 | - ); |
339 | - if (s->rx_compressed) |
340 | - fprintf(fp, " %-7u", s->rx_compressed); |
341 | - if (show_stats > 1) { |
342 | - fprintf(fp, "%s", _SL_); |
343 | - fprintf(fp, " RX errors: length crc frame fifo missed%s", _SL_); |
344 | - fprintf(fp, " %-7u %-7u %-7u %-7u %-7u", |
345 | - s->rx_length_errors, |
346 | - s->rx_crc_errors, |
347 | - s->rx_frame_errors, |
348 | - s->rx_fifo_errors, |
349 | - s->rx_missed_errors |
350 | - ); |
351 | - } |
352 | - fprintf(fp, "%s", _SL_); |
353 | - fprintf(fp, " TX: bytes packets errors dropped carrier collsns %s%s", |
354 | - s->tx_compressed ? "compressed" : "", _SL_); |
355 | - fprintf(fp, " %-10u %-8u %-7u %-7u %-7u %-7u", |
356 | - s->tx_bytes, s->tx_packets, s->tx_errors, |
357 | - s->tx_dropped, s->tx_carrier_errors, s->collisions); |
358 | - if (s->tx_compressed) |
359 | - fprintf(fp, " %-7u", s->tx_compressed); |
360 | - if (show_stats > 1) { |
361 | - fprintf(fp, "%s", _SL_); |
362 | - fprintf(fp, " TX errors: aborted fifo window heartbeat%s", _SL_); |
363 | - fprintf(fp, " %-7u %-7u %-7u %-7u", |
364 | - s->tx_aborted_errors, |
365 | - s->tx_fifo_errors, |
366 | - s->tx_window_errors, |
367 | - s->tx_heartbeat_errors |
368 | - ); |
369 | - } |
370 | -} |
371 | - |
372 | -int print_linkinfo(const struct sockaddr_nl *who, |
373 | - struct nlmsghdr *n, void *arg) |
374 | -{ |
375 | - FILE *fp = (FILE*)arg; |
376 | - struct ifinfomsg *ifi = NLMSG_DATA(n); |
377 | - struct rtattr * tb[IFLA_MAX+1]; |
378 | - int len = n->nlmsg_len; |
379 | - unsigned m_flag = 0; |
380 | - |
381 | - if (n->nlmsg_type != RTM_NEWLINK && n->nlmsg_type != RTM_DELLINK) |
382 | - return 0; |
383 | - |
384 | - len -= NLMSG_LENGTH(sizeof(*ifi)); |
385 | - if (len < 0) |
386 | - return -1; |
387 | - |
388 | - if (filter.ifindex && ifi->ifi_index != filter.ifindex) |
389 | - return 0; |
390 | - if (filter.up && !(ifi->ifi_flags&IFF_UP)) |
391 | - return 0; |
392 | - |
393 | - parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len); |
394 | - if (tb[IFLA_IFNAME] == NULL) { |
395 | - fprintf(stderr, "BUG: device with ifindex %d has nil ifname\n", ifi->ifi_index); |
396 | - } |
397 | - if (filter.label && |
398 | - (!filter.family || filter.family == AF_PACKET) && |
399 | - fnmatch(filter.label, RTA_DATA(tb[IFLA_IFNAME]), 0)) |
400 | - return 0; |
401 | - |
402 | - if (tb[IFLA_GROUP]) { |
403 | - int group = *(int*)RTA_DATA(tb[IFLA_GROUP]); |
404 | - if (group != filter.group) |
405 | - return -1; |
406 | - } |
407 | - |
408 | - if (n->nlmsg_type == RTM_DELLINK) |
409 | - fprintf(fp, "Deleted "); |
410 | - |
411 | - fprintf(fp, "%d: %s", ifi->ifi_index, |
412 | - tb[IFLA_IFNAME] ? rta_getattr_str(tb[IFLA_IFNAME]) : "<nil>"); |
413 | - |
414 | - if (tb[IFLA_LINK]) { |
415 | - SPRINT_BUF(b1); |
416 | - int iflink = *(int*)RTA_DATA(tb[IFLA_LINK]); |
417 | - if (iflink == 0) |
418 | - fprintf(fp, "@NONE: "); |
419 | - else { |
420 | - fprintf(fp, "@%s: ", ll_idx_n2a(iflink, b1)); |
421 | - m_flag = ll_index_to_flags(iflink); |
422 | - m_flag = !(m_flag & IFF_UP); |
423 | - } |
424 | - } else { |
425 | - fprintf(fp, ": "); |
426 | - } |
427 | - print_link_flags(fp, ifi->ifi_flags, m_flag); |
428 | - |
429 | - if (tb[IFLA_MTU]) |
430 | - fprintf(fp, "mtu %u ", *(int*)RTA_DATA(tb[IFLA_MTU])); |
431 | - if (tb[IFLA_QDISC]) |
432 | - fprintf(fp, "qdisc %s ", rta_getattr_str(tb[IFLA_QDISC])); |
433 | - if (tb[IFLA_MASTER]) { |
434 | - SPRINT_BUF(b1); |
435 | - fprintf(fp, "master %s ", ll_idx_n2a(*(int*)RTA_DATA(tb[IFLA_MASTER]), b1)); |
436 | - } |
437 | - |
438 | - if (tb[IFLA_OPERSTATE]) |
439 | - print_operstate(fp, rta_getattr_u8(tb[IFLA_OPERSTATE])); |
440 | - |
441 | - if (do_link && tb[IFLA_LINKMODE]) |
442 | - print_linkmode(fp, tb[IFLA_LINKMODE]); |
443 | - |
444 | - if (filter.showqueue) |
445 | - print_queuelen(fp, tb); |
446 | - |
447 | - if (!filter.family || filter.family == AF_PACKET) { |
448 | - SPRINT_BUF(b1); |
449 | - fprintf(fp, "%s", _SL_); |
450 | - fprintf(fp, " link/%s ", ll_type_n2a(ifi->ifi_type, b1, sizeof(b1))); |
451 | - |
452 | - if (tb[IFLA_ADDRESS]) { |
453 | - fprintf(fp, "%s", ll_addr_n2a(RTA_DATA(tb[IFLA_ADDRESS]), |
454 | - RTA_PAYLOAD(tb[IFLA_ADDRESS]), |
455 | - ifi->ifi_type, |
456 | - b1, sizeof(b1))); |
457 | - } |
458 | - if (tb[IFLA_BROADCAST]) { |
459 | - if (ifi->ifi_flags&IFF_POINTOPOINT) |
460 | - fprintf(fp, " peer "); |
461 | - else |
462 | - fprintf(fp, " brd "); |
463 | - fprintf(fp, "%s", ll_addr_n2a(RTA_DATA(tb[IFLA_BROADCAST]), |
464 | - RTA_PAYLOAD(tb[IFLA_BROADCAST]), |
465 | - ifi->ifi_type, |
466 | - b1, sizeof(b1))); |
467 | - } |
468 | - } |
469 | - |
470 | - if (do_link && tb[IFLA_LINKINFO] && show_details) |
471 | - print_linktype(fp, tb[IFLA_LINKINFO]); |
472 | - |
473 | - if (do_link && tb[IFLA_IFALIAS]) |
474 | - fprintf(fp,"\n alias %s", |
475 | - rta_getattr_str(tb[IFLA_IFALIAS])); |
476 | - |
477 | - if (do_link && show_stats) { |
478 | - if (tb[IFLA_STATS64]) |
479 | - print_link_stats64(fp, RTA_DATA(tb[IFLA_STATS64])); |
480 | - else if (tb[IFLA_STATS]) |
481 | - print_link_stats(fp, RTA_DATA(tb[IFLA_STATS])); |
482 | - } |
483 | - |
484 | - if (do_link && tb[IFLA_VFINFO_LIST] && tb[IFLA_NUM_VF]) { |
485 | - struct rtattr *i, *vflist = tb[IFLA_VFINFO_LIST]; |
486 | - int rem = RTA_PAYLOAD(vflist); |
487 | - for (i = RTA_DATA(vflist); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) |
488 | - print_vfinfo(fp, i); |
489 | - } |
490 | - |
491 | - fprintf(fp, "\n"); |
492 | - fflush(fp); |
493 | - return 0; |
494 | -} |
495 | - |
496 | -static int flush_update(void) |
497 | -{ |
498 | - if (rtnl_send_check(&rth, filter.flushb, filter.flushp) < 0) { |
499 | - perror("Failed to send flush request"); |
500 | - return -1; |
501 | - } |
502 | - filter.flushp = 0; |
503 | - return 0; |
504 | -} |
505 | - |
506 | -static int set_lifetime(unsigned int *lifetime, char *argv) |
507 | -{ |
508 | - if (strcmp(argv, "forever") == 0) |
509 | - *lifetime = INFINITY_LIFE_TIME; |
510 | - else if (get_u32(lifetime, argv, 0)) |
511 | - return -1; |
512 | - |
513 | - return 0; |
514 | -} |
515 | - |
516 | -int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n, |
517 | - void *arg) |
518 | -{ |
519 | - FILE *fp = (FILE*)arg; |
520 | - struct ifaddrmsg *ifa = NLMSG_DATA(n); |
521 | - int len = n->nlmsg_len; |
522 | - int deprecated = 0; |
523 | - /* Use local copy of ifa_flags to not interfere with filtering code */ |
524 | - unsigned int ifa_flags; |
525 | - struct rtattr * rta_tb[IFA_MAX+1]; |
526 | - char abuf[256]; |
527 | - SPRINT_BUF(b1); |
528 | - |
529 | - if (n->nlmsg_type != RTM_NEWADDR && n->nlmsg_type != RTM_DELADDR) |
530 | - return 0; |
531 | - len -= NLMSG_LENGTH(sizeof(*ifa)); |
532 | - if (len < 0) { |
533 | - fprintf(stderr, "BUG: wrong nlmsg len %d\n", len); |
534 | - return -1; |
535 | - } |
536 | - |
537 | - if (filter.flushb && n->nlmsg_type != RTM_NEWADDR) |
538 | - return 0; |
539 | - |
540 | - parse_rtattr(rta_tb, IFA_MAX, IFA_RTA(ifa), n->nlmsg_len - NLMSG_LENGTH(sizeof(*ifa))); |
541 | - |
542 | - if (!rta_tb[IFA_LOCAL]) |
543 | - rta_tb[IFA_LOCAL] = rta_tb[IFA_ADDRESS]; |
544 | - if (!rta_tb[IFA_ADDRESS]) |
545 | - rta_tb[IFA_ADDRESS] = rta_tb[IFA_LOCAL]; |
546 | - |
547 | - if (filter.ifindex && filter.ifindex != ifa->ifa_index) |
548 | - return 0; |
549 | - if ((filter.scope^ifa->ifa_scope)&filter.scopemask) |
550 | - return 0; |
551 | - if ((filter.flags^ifa->ifa_flags)&filter.flagmask) |
552 | - return 0; |
553 | - if (filter.label) { |
554 | - SPRINT_BUF(b1); |
555 | - const char *label; |
556 | - if (rta_tb[IFA_LABEL]) |
557 | - label = RTA_DATA(rta_tb[IFA_LABEL]); |
558 | - else |
559 | - label = ll_idx_n2a(ifa->ifa_index, b1); |
560 | - if (fnmatch(filter.label, label, 0) != 0) |
561 | - return 0; |
562 | - } |
563 | - if (filter.pfx.family) { |
564 | - if (rta_tb[IFA_LOCAL]) { |
565 | - inet_prefix dst; |
566 | - memset(&dst, 0, sizeof(dst)); |
567 | - dst.family = ifa->ifa_family; |
568 | - memcpy(&dst.data, RTA_DATA(rta_tb[IFA_LOCAL]), RTA_PAYLOAD(rta_tb[IFA_LOCAL])); |
569 | - if (inet_addr_match(&dst, &filter.pfx, filter.pfx.bitlen)) |
570 | - return 0; |
571 | - } |
572 | - } |
573 | - |
574 | - if (filter.family && filter.family != ifa->ifa_family) |
575 | - return 0; |
576 | - |
577 | - if (filter.flushb) { |
578 | - struct nlmsghdr *fn; |
579 | - if (NLMSG_ALIGN(filter.flushp) + n->nlmsg_len > filter.flushe) { |
580 | - if (flush_update()) |
581 | - return -1; |
582 | - } |
583 | - fn = (struct nlmsghdr*)(filter.flushb + NLMSG_ALIGN(filter.flushp)); |
584 | - memcpy(fn, n, n->nlmsg_len); |
585 | - fn->nlmsg_type = RTM_DELADDR; |
586 | - fn->nlmsg_flags = NLM_F_REQUEST; |
587 | - fn->nlmsg_seq = ++rth.seq; |
588 | - filter.flushp = (((char*)fn) + n->nlmsg_len) - filter.flushb; |
589 | - filter.flushed++; |
590 | - if (show_stats < 2) |
591 | - return 0; |
592 | - } |
593 | - |
594 | - if (n->nlmsg_type == RTM_DELADDR) |
595 | - fprintf(fp, "Deleted "); |
596 | - |
597 | - if (filter.oneline || filter.flushb) |
598 | - fprintf(fp, "%u: %s", ifa->ifa_index, ll_index_to_name(ifa->ifa_index)); |
599 | - if (ifa->ifa_family == AF_INET) |
600 | - fprintf(fp, " inet "); |
601 | - else if (ifa->ifa_family == AF_INET6) |
602 | - fprintf(fp, " inet6 "); |
603 | - else if (ifa->ifa_family == AF_DECnet) |
604 | - fprintf(fp, " dnet "); |
605 | - else if (ifa->ifa_family == AF_IPX) |
606 | - fprintf(fp, " ipx "); |
607 | - else |
608 | - fprintf(fp, " family %d ", ifa->ifa_family); |
609 | - |
610 | - if (rta_tb[IFA_LOCAL]) { |
611 | - fprintf(fp, "%s", rt_addr_n2a(ifa->ifa_family, |
612 | - RTA_PAYLOAD(rta_tb[IFA_LOCAL]), |
613 | - RTA_DATA(rta_tb[IFA_LOCAL]), |
614 | - abuf, sizeof(abuf))); |
615 | - |
616 | - if (rta_tb[IFA_ADDRESS] == NULL || |
617 | - memcmp(RTA_DATA(rta_tb[IFA_ADDRESS]), RTA_DATA(rta_tb[IFA_LOCAL]), 4) == 0) { |
618 | - fprintf(fp, "/%d ", ifa->ifa_prefixlen); |
619 | - } else { |
620 | - fprintf(fp, " peer %s/%d ", |
621 | - rt_addr_n2a(ifa->ifa_family, |
622 | - RTA_PAYLOAD(rta_tb[IFA_ADDRESS]), |
623 | - RTA_DATA(rta_tb[IFA_ADDRESS]), |
624 | - abuf, sizeof(abuf)), |
625 | - ifa->ifa_prefixlen); |
626 | - } |
627 | - } |
628 | - |
629 | - if (rta_tb[IFA_BROADCAST]) { |
630 | - fprintf(fp, "brd %s ", |
631 | - rt_addr_n2a(ifa->ifa_family, |
632 | - RTA_PAYLOAD(rta_tb[IFA_BROADCAST]), |
633 | - RTA_DATA(rta_tb[IFA_BROADCAST]), |
634 | - abuf, sizeof(abuf))); |
635 | - } |
636 | - if (rta_tb[IFA_ANYCAST]) { |
637 | - fprintf(fp, "any %s ", |
638 | - rt_addr_n2a(ifa->ifa_family, |
639 | - RTA_PAYLOAD(rta_tb[IFA_ANYCAST]), |
640 | - RTA_DATA(rta_tb[IFA_ANYCAST]), |
641 | - abuf, sizeof(abuf))); |
642 | - } |
643 | - fprintf(fp, "scope %s ", rtnl_rtscope_n2a(ifa->ifa_scope, b1, sizeof(b1))); |
644 | - ifa_flags = ifa->ifa_flags; |
645 | - if (ifa->ifa_flags&IFA_F_SECONDARY) { |
646 | - ifa_flags &= ~IFA_F_SECONDARY; |
647 | - if (ifa->ifa_family == AF_INET6) |
648 | - fprintf(fp, "temporary "); |
649 | - else |
650 | - fprintf(fp, "secondary "); |
651 | - } |
652 | - if (ifa->ifa_flags&IFA_F_TENTATIVE) { |
653 | - ifa_flags &= ~IFA_F_TENTATIVE; |
654 | - fprintf(fp, "tentative "); |
655 | - } |
656 | - if (ifa->ifa_flags&IFA_F_DEPRECATED) { |
657 | - ifa_flags &= ~IFA_F_DEPRECATED; |
658 | - deprecated = 1; |
659 | - fprintf(fp, "deprecated "); |
660 | - } |
661 | - if (ifa->ifa_flags&IFA_F_HOMEADDRESS) { |
662 | - ifa_flags &= ~IFA_F_HOMEADDRESS; |
663 | - fprintf(fp, "home "); |
664 | - } |
665 | - if (ifa->ifa_flags&IFA_F_NODAD) { |
666 | - ifa_flags &= ~IFA_F_NODAD; |
667 | - fprintf(fp, "nodad "); |
668 | - } |
669 | - if (!(ifa->ifa_flags&IFA_F_PERMANENT)) { |
670 | - fprintf(fp, "dynamic "); |
671 | - } else |
672 | - ifa_flags &= ~IFA_F_PERMANENT; |
673 | - if (ifa->ifa_flags&IFA_F_DADFAILED) { |
674 | - ifa_flags &= ~IFA_F_DADFAILED; |
675 | - fprintf(fp, "dadfailed "); |
676 | - } |
677 | - if (ifa_flags) |
678 | - fprintf(fp, "flags %02x ", ifa_flags); |
679 | - if (rta_tb[IFA_LABEL]) |
680 | - fprintf(fp, "%s", rta_getattr_str(rta_tb[IFA_LABEL])); |
681 | - if (rta_tb[IFA_CACHEINFO]) { |
682 | - struct ifa_cacheinfo *ci = RTA_DATA(rta_tb[IFA_CACHEINFO]); |
683 | - fprintf(fp, "%s", _SL_); |
684 | - fprintf(fp, " valid_lft "); |
685 | - if (ci->ifa_valid == INFINITY_LIFE_TIME) |
686 | - fprintf(fp, "forever"); |
687 | - else |
688 | - fprintf(fp, "%usec", ci->ifa_valid); |
689 | - fprintf(fp, " preferred_lft "); |
690 | - if (ci->ifa_prefered == INFINITY_LIFE_TIME) |
691 | - fprintf(fp, "forever"); |
692 | - else { |
693 | - if (deprecated) |
694 | - fprintf(fp, "%dsec", ci->ifa_prefered); |
695 | - else |
696 | - fprintf(fp, "%usec", ci->ifa_prefered); |
697 | - } |
698 | - } |
699 | - fprintf(fp, "\n"); |
700 | - fflush(fp); |
701 | - return 0; |
702 | -} |
703 | - |
704 | -int print_addrinfo_primary(const struct sockaddr_nl *who, struct nlmsghdr *n, |
705 | - void *arg) |
706 | -{ |
707 | - struct ifaddrmsg *ifa = NLMSG_DATA(n); |
708 | - |
709 | - if (ifa->ifa_flags & IFA_F_SECONDARY) |
710 | - return 0; |
711 | - |
712 | - return print_addrinfo(who, n, arg); |
713 | -} |
714 | - |
715 | -int print_addrinfo_secondary(const struct sockaddr_nl *who, struct nlmsghdr *n, |
716 | - void *arg) |
717 | -{ |
718 | - struct ifaddrmsg *ifa = NLMSG_DATA(n); |
719 | - |
720 | - if (!(ifa->ifa_flags & IFA_F_SECONDARY)) |
721 | - return 0; |
722 | - |
723 | - return print_addrinfo(who, n, arg); |
724 | -} |
725 | - |
726 | -struct nlmsg_list |
727 | -{ |
728 | - struct nlmsg_list *next; |
729 | - struct nlmsghdr h; |
730 | -}; |
731 | - |
732 | -struct nlmsg_chain |
733 | -{ |
734 | - struct nlmsg_list *head; |
735 | - struct nlmsg_list *tail; |
736 | -}; |
737 | - |
738 | -static int print_selected_addrinfo(int ifindex, struct nlmsg_list *ainfo, FILE *fp) |
739 | -{ |
740 | - for ( ;ainfo ; ainfo = ainfo->next) { |
741 | - struct nlmsghdr *n = &ainfo->h; |
742 | - struct ifaddrmsg *ifa = NLMSG_DATA(n); |
743 | - |
744 | - if (n->nlmsg_type != RTM_NEWADDR) |
745 | - continue; |
746 | - |
747 | - if (n->nlmsg_len < NLMSG_LENGTH(sizeof(ifa))) |
748 | - return -1; |
749 | - |
750 | - if (ifa->ifa_index != ifindex || |
751 | - (filter.family && filter.family != ifa->ifa_family)) |
752 | - continue; |
753 | - |
754 | - print_addrinfo(NULL, n, fp); |
755 | - } |
756 | - return 0; |
757 | -} |
758 | - |
759 | - |
760 | -static int store_nlmsg(const struct sockaddr_nl *who, struct nlmsghdr *n, |
761 | - void *arg) |
762 | -{ |
763 | - struct nlmsg_chain *lchain = (struct nlmsg_chain *)arg; |
764 | - struct nlmsg_list *h; |
765 | - |
766 | - h = malloc(n->nlmsg_len+sizeof(void*)); |
767 | - if (h == NULL) |
768 | - return -1; |
769 | - |
770 | - memcpy(&h->h, n, n->nlmsg_len); |
771 | - h->next = NULL; |
772 | - |
773 | - if (lchain->tail) |
774 | - lchain->tail->next = h; |
775 | - else |
776 | - lchain->head = h; |
777 | - lchain->tail = h; |
778 | - |
779 | - ll_remember_index(who, n, NULL); |
780 | - return 0; |
781 | -} |
782 | - |
783 | -static __u32 ipadd_dump_magic = 0x47361222; |
784 | - |
785 | -static int ipadd_save_prep(void) |
786 | -{ |
787 | - int ret; |
788 | - |
789 | - if (isatty(STDOUT_FILENO)) { |
790 | - fprintf(stderr, "Not sending binary stream to stdout\n"); |
791 | - return -1; |
792 | - } |
793 | - |
794 | - ret = write(STDOUT_FILENO, &ipadd_dump_magic, sizeof(ipadd_dump_magic)); |
795 | - if (ret != sizeof(ipadd_dump_magic)) { |
796 | - fprintf(stderr, "Can't write magic to dump file\n"); |
797 | - return -1; |
798 | - } |
799 | - |
800 | - return 0; |
801 | -} |
802 | - |
803 | -static int ipadd_dump_check_magic(void) |
804 | -{ |
805 | - int ret; |
806 | - __u32 magic = 0; |
807 | - |
808 | - if (isatty(STDIN_FILENO)) { |
809 | - fprintf(stderr, "Can't restore addr dump from a terminal\n"); |
810 | - return -1; |
811 | - } |
812 | - |
813 | - ret = fread(&magic, sizeof(magic), 1, stdin); |
814 | - if (magic != ipadd_dump_magic) { |
815 | - fprintf(stderr, "Magic mismatch (%d elems, %x magic)\n", ret, magic); |
816 | - return -1; |
817 | - } |
818 | - |
819 | - return 0; |
820 | -} |
821 | - |
822 | -static int save_nlmsg(const struct sockaddr_nl *who, struct nlmsghdr *n, |
823 | - void *arg) |
824 | -{ |
825 | - int ret; |
826 | - |
827 | - ret = write(STDOUT_FILENO, n, n->nlmsg_len); |
828 | - if ((ret > 0) && (ret != n->nlmsg_len)) { |
829 | - fprintf(stderr, "Short write while saving nlmsg\n"); |
830 | - ret = -EIO; |
831 | - } |
832 | - |
833 | - return ret == n->nlmsg_len ? 0 : ret; |
834 | -} |
835 | - |
836 | -static int show_handler(const struct sockaddr_nl *nl, struct nlmsghdr *n, void *arg) |
837 | -{ |
838 | - struct ifaddrmsg *ifa = NLMSG_DATA(n); |
839 | - |
840 | - printf("if%d:\n", ifa->ifa_index); |
841 | - print_addrinfo(NULL, n, stdout); |
842 | - return 0; |
843 | -} |
844 | - |
845 | -static int ipaddr_showdump(void) |
846 | -{ |
847 | - if (ipadd_dump_check_magic()) |
848 | - exit(-1); |
849 | - |
850 | - exit(rtnl_from_file(stdin, &show_handler, NULL)); |
851 | -} |
852 | - |
853 | -static int restore_handler(const struct sockaddr_nl *nl, struct nlmsghdr *n, void *arg) |
854 | -{ |
855 | - int ret; |
856 | - |
857 | - n->nlmsg_flags |= NLM_F_REQUEST | NLM_F_CREATE | NLM_F_ACK; |
858 | - |
859 | - ll_init_map(&rth); |
860 | - |
861 | - ret = rtnl_talk(&rth, n, 0, 0, n); |
862 | - if ((ret < 0) && (errno == EEXIST)) |
863 | - ret = 0; |
864 | - |
865 | - return ret; |
866 | -} |
867 | - |
868 | -static int ipaddr_restore(void) |
869 | -{ |
870 | - if (ipadd_dump_check_magic()) |
871 | - exit(-1); |
872 | - |
873 | - exit(rtnl_from_file(stdin, &restore_handler, NULL)); |
874 | -} |
875 | - |
876 | -static void free_nlmsg_chain(struct nlmsg_chain *info) |
877 | -{ |
878 | - struct nlmsg_list *l, *n; |
879 | - |
880 | - for (l = info->head; l; l = n) { |
881 | - n = l->next; |
882 | - free(l); |
883 | - } |
884 | -} |
885 | - |
886 | -static void ipaddr_filter(struct nlmsg_chain *linfo, struct nlmsg_chain *ainfo) |
887 | -{ |
888 | - struct nlmsg_list *l, **lp; |
889 | - |
890 | - lp = &linfo->head; |
891 | - while ( (l = *lp) != NULL) { |
892 | - int ok = 0; |
893 | - struct ifinfomsg *ifi = NLMSG_DATA(&l->h); |
894 | - struct nlmsg_list *a; |
895 | - |
896 | - for (a = ainfo->head; a; a = a->next) { |
897 | - struct nlmsghdr *n = &a->h; |
898 | - struct ifaddrmsg *ifa = NLMSG_DATA(n); |
899 | - |
900 | - if (ifa->ifa_index != ifi->ifi_index || |
901 | - (filter.family && filter.family != ifa->ifa_family)) |
902 | - continue; |
903 | - if ((filter.scope^ifa->ifa_scope)&filter.scopemask) |
904 | - continue; |
905 | - if ((filter.flags^ifa->ifa_flags)&filter.flagmask) |
906 | - continue; |
907 | - if (filter.pfx.family || filter.label) { |
908 | - struct rtattr *tb[IFA_MAX+1]; |
909 | - parse_rtattr(tb, IFA_MAX, IFA_RTA(ifa), IFA_PAYLOAD(n)); |
910 | - if (!tb[IFA_LOCAL]) |
911 | - tb[IFA_LOCAL] = tb[IFA_ADDRESS]; |
912 | - |
913 | - if (filter.pfx.family && tb[IFA_LOCAL]) { |
914 | - inet_prefix dst; |
915 | - memset(&dst, 0, sizeof(dst)); |
916 | - dst.family = ifa->ifa_family; |
917 | - memcpy(&dst.data, RTA_DATA(tb[IFA_LOCAL]), RTA_PAYLOAD(tb[IFA_LOCAL])); |
918 | - if (inet_addr_match(&dst, &filter.pfx, filter.pfx.bitlen)) |
919 | - continue; |
920 | - } |
921 | - if (filter.label) { |
922 | - SPRINT_BUF(b1); |
923 | - const char *label; |
924 | - if (tb[IFA_LABEL]) |
925 | - label = RTA_DATA(tb[IFA_LABEL]); |
926 | - else |
927 | - label = ll_idx_n2a(ifa->ifa_index, b1); |
928 | - if (fnmatch(filter.label, label, 0) != 0) |
929 | - continue; |
930 | - } |
931 | - } |
932 | - |
933 | - ok = 1; |
934 | - break; |
935 | - } |
936 | - if (!ok) { |
937 | - *lp = l->next; |
938 | - free(l); |
939 | - } else |
940 | - lp = &l->next; |
941 | - } |
942 | -} |
943 | - |
944 | -static int ipaddr_flush(void) |
945 | -{ |
946 | - int round = 0; |
947 | - char flushb[4096-512]; |
948 | - |
949 | - filter.flushb = flushb; |
950 | - filter.flushp = 0; |
951 | - filter.flushe = sizeof(flushb); |
952 | - |
953 | - while ((max_flush_loops == 0) || (round < max_flush_loops)) { |
954 | - const struct rtnl_dump_filter_arg a[3] = { |
955 | - { |
956 | - .filter = print_addrinfo_secondary, |
957 | - .arg1 = stdout, |
958 | - }, |
959 | - { |
960 | - .filter = print_addrinfo_primary, |
961 | - .arg1 = stdout, |
962 | - }, |
963 | - { |
964 | - .filter = NULL, |
965 | - .arg1 = NULL, |
966 | - }, |
967 | - }; |
968 | - if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) { |
969 | - perror("Cannot send dump request"); |
970 | - exit(1); |
971 | - } |
972 | - filter.flushed = 0; |
973 | - if (rtnl_dump_filter_l(&rth, a) < 0) { |
974 | - fprintf(stderr, "Flush terminated\n"); |
975 | - exit(1); |
976 | - } |
977 | - if (filter.flushed == 0) { |
978 | - flush_done: |
979 | - if (show_stats) { |
980 | - if (round == 0) |
981 | - printf("Nothing to flush.\n"); |
982 | - else |
983 | - printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":""); |
984 | - } |
985 | - fflush(stdout); |
986 | - return 0; |
987 | - } |
988 | - round++; |
989 | - if (flush_update() < 0) |
990 | - return 1; |
991 | - |
992 | - if (show_stats) { |
993 | - printf("\n*** Round %d, deleting %d addresses ***\n", round, filter.flushed); |
994 | - fflush(stdout); |
995 | - } |
996 | - |
997 | - /* If we are flushing, and specifying primary, then we |
998 | - * want to flush only a single round. Otherwise, we'll |
999 | - * start flushing secondaries that were promoted to |
1000 | - * primaries. |
1001 | - */ |
1002 | - if (!(filter.flags & IFA_F_SECONDARY) && (filter.flagmask & IFA_F_SECONDARY)) |
1003 | - goto flush_done; |
1004 | - } |
1005 | - fprintf(stderr, "*** Flush remains incomplete after %d rounds. ***\n", max_flush_loops); |
1006 | - fflush(stderr); |
1007 | - return 1; |
1008 | -} |
1009 | - |
1010 | -static int ipaddr_list_flush_or_save(int argc, char **argv, int action) |
1011 | -{ |
1012 | - struct nlmsg_chain linfo = { NULL, NULL}; |
1013 | - struct nlmsg_chain ainfo = { NULL, NULL}; |
1014 | - struct nlmsg_list *l; |
1015 | - char *filter_dev = NULL; |
1016 | - int no_link = 0; |
1017 | - |
1018 | - ipaddr_reset_filter(oneline); |
1019 | - filter.showqueue = 1; |
1020 | - |
1021 | - if (filter.family == AF_UNSPEC) |
1022 | - filter.family = preferred_family; |
1023 | - |
1024 | - filter.group = INIT_NETDEV_GROUP; |
1025 | - |
1026 | - if (action == IPADD_FLUSH) { |
1027 | - if (argc <= 0) { |
1028 | - fprintf(stderr, "Flush requires arguments.\n"); |
1029 | - |
1030 | - return -1; |
1031 | - } |
1032 | - if (filter.family == AF_PACKET) { |
1033 | - fprintf(stderr, "Cannot flush link addresses.\n"); |
1034 | - return -1; |
1035 | - } |
1036 | - } |
1037 | - |
1038 | - while (argc > 0) { |
1039 | - if (strcmp(*argv, "to") == 0) { |
1040 | - NEXT_ARG(); |
1041 | - get_prefix(&filter.pfx, *argv, filter.family); |
1042 | - if (filter.family == AF_UNSPEC) |
1043 | - filter.family = filter.pfx.family; |
1044 | - } else if (strcmp(*argv, "scope") == 0) { |
1045 | - unsigned scope = 0; |
1046 | - NEXT_ARG(); |
1047 | - filter.scopemask = -1; |
1048 | - if (rtnl_rtscope_a2n(&scope, *argv)) { |
1049 | - if (strcmp(*argv, "all") != 0) |
1050 | - invarg("invalid \"scope\"\n", *argv); |
1051 | - scope = RT_SCOPE_NOWHERE; |
1052 | - filter.scopemask = 0; |
1053 | - } |
1054 | - filter.scope = scope; |
1055 | - } else if (strcmp(*argv, "up") == 0) { |
1056 | - filter.up = 1; |
1057 | - } else if (strcmp(*argv, "dynamic") == 0) { |
1058 | - filter.flags &= ~IFA_F_PERMANENT; |
1059 | - filter.flagmask |= IFA_F_PERMANENT; |
1060 | - } else if (strcmp(*argv, "permanent") == 0) { |
1061 | - filter.flags |= IFA_F_PERMANENT; |
1062 | - filter.flagmask |= IFA_F_PERMANENT; |
1063 | - } else if (strcmp(*argv, "secondary") == 0 || |
1064 | - strcmp(*argv, "temporary") == 0) { |
1065 | - filter.flags |= IFA_F_SECONDARY; |
1066 | - filter.flagmask |= IFA_F_SECONDARY; |
1067 | - } else if (strcmp(*argv, "primary") == 0) { |
1068 | - filter.flags &= ~IFA_F_SECONDARY; |
1069 | - filter.flagmask |= IFA_F_SECONDARY; |
1070 | - } else if (strcmp(*argv, "tentative") == 0) { |
1071 | - filter.flags |= IFA_F_TENTATIVE; |
1072 | - filter.flagmask |= IFA_F_TENTATIVE; |
1073 | - } else if (strcmp(*argv, "deprecated") == 0) { |
1074 | - filter.flags |= IFA_F_DEPRECATED; |
1075 | - filter.flagmask |= IFA_F_DEPRECATED; |
1076 | - } else if (strcmp(*argv, "home") == 0) { |
1077 | - filter.flags |= IFA_F_HOMEADDRESS; |
1078 | - filter.flagmask |= IFA_F_HOMEADDRESS; |
1079 | - } else if (strcmp(*argv, "nodad") == 0) { |
1080 | - filter.flags |= IFA_F_NODAD; |
1081 | - filter.flagmask |= IFA_F_NODAD; |
1082 | - } else if (strcmp(*argv, "dadfailed") == 0) { |
1083 | - filter.flags |= IFA_F_DADFAILED; |
1084 | - filter.flagmask |= IFA_F_DADFAILED; |
1085 | - } else if (strcmp(*argv, "label") == 0) { |
1086 | - NEXT_ARG(); |
1087 | - filter.label = *argv; |
1088 | - } else if (strcmp(*argv, "group") == 0) { |
1089 | - NEXT_ARG(); |
1090 | - if (rtnl_group_a2n(&filter.group, *argv)) |
1091 | - invarg("Invalid \"group\" value\n", *argv); |
1092 | - } else { |
1093 | - if (strcmp(*argv, "dev") == 0) { |
1094 | - NEXT_ARG(); |
1095 | - } |
1096 | - if (matches(*argv, "help") == 0) |
1097 | - usage(); |
1098 | - if (filter_dev) |
1099 | - duparg2("dev", *argv); |
1100 | - filter_dev = *argv; |
1101 | - } |
1102 | - argv++; argc--; |
1103 | - } |
1104 | - |
1105 | - if (filter_dev) { |
1106 | - filter.ifindex = ll_name_to_index(filter_dev); |
1107 | - if (filter.ifindex <= 0) { |
1108 | - fprintf(stderr, "Device \"%s\" does not exist.\n", filter_dev); |
1109 | - return -1; |
1110 | - } |
1111 | - } |
1112 | - |
1113 | - if (action == IPADD_FLUSH) |
1114 | - return ipaddr_flush(); |
1115 | - |
1116 | - if (action == IPADD_SAVE) { |
1117 | - if (ipadd_save_prep()) |
1118 | - exit(1); |
1119 | - |
1120 | - if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETADDR) < 0) { |
1121 | - perror("Cannot send dump request"); |
1122 | - exit(1); |
1123 | - } |
1124 | - |
1125 | - if (rtnl_dump_filter(&rth, save_nlmsg, stdout) < 0) { |
1126 | - fprintf(stderr, "Save terminated\n"); |
1127 | - exit(1); |
1128 | - } |
1129 | - |
1130 | - exit(0); |
1131 | - } |
1132 | - |
1133 | - if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETLINK) < 0) { |
1134 | - perror("Cannot send dump request"); |
1135 | - exit(1); |
1136 | - } |
1137 | - |
1138 | - if (rtnl_dump_filter(&rth, store_nlmsg, &linfo) < 0) { |
1139 | - fprintf(stderr, "Dump terminated\n"); |
1140 | - exit(1); |
1141 | - } |
1142 | - |
1143 | - if (filter.family != AF_PACKET) { |
1144 | - if (filter.oneline) |
1145 | - no_link = 1; |
1146 | - |
1147 | - if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) { |
1148 | - perror("Cannot send dump request"); |
1149 | - exit(1); |
1150 | - } |
1151 | - |
1152 | - if (rtnl_dump_filter(&rth, store_nlmsg, &ainfo) < 0) { |
1153 | - fprintf(stderr, "Dump terminated\n"); |
1154 | - exit(1); |
1155 | - } |
1156 | - |
1157 | - ipaddr_filter(&linfo, &ainfo); |
1158 | - } |
1159 | - |
1160 | - for (l = linfo.head; l; l = l->next) { |
1161 | - if (no_link || print_linkinfo(NULL, &l->h, stdout) == 0) { |
1162 | - struct ifinfomsg *ifi = NLMSG_DATA(&l->h); |
1163 | - if (filter.family != AF_PACKET) |
1164 | - print_selected_addrinfo(ifi->ifi_index, |
1165 | - ainfo.head, stdout); |
1166 | - } |
1167 | - } |
1168 | - fflush(stdout); |
1169 | - |
1170 | - free_nlmsg_chain(&ainfo); |
1171 | - free_nlmsg_chain(&linfo); |
1172 | - |
1173 | - return 0; |
1174 | -} |
1175 | - |
1176 | -int ipaddr_list_link(int argc, char **argv) |
1177 | -{ |
1178 | - preferred_family = AF_PACKET; |
1179 | - do_link = 1; |
1180 | - return ipaddr_list_flush_or_save(argc, argv, IPADD_LIST); |
1181 | -} |
1182 | - |
1183 | -void ipaddr_reset_filter(int oneline) |
1184 | -{ |
1185 | - memset(&filter, 0, sizeof(filter)); |
1186 | - filter.oneline = oneline; |
1187 | -} |
1188 | - |
1189 | -static int default_scope(inet_prefix *lcl) |
1190 | -{ |
1191 | - if (lcl->family == AF_INET) { |
1192 | - if (lcl->bytelen >= 1 && *(__u8*)&lcl->data == 127) |
1193 | - return RT_SCOPE_HOST; |
1194 | - } |
1195 | - return 0; |
1196 | -} |
1197 | - |
1198 | -static int ipaddr_modify(int cmd, int flags, int argc, char **argv) |
1199 | -{ |
1200 | - struct { |
1201 | - struct nlmsghdr n; |
1202 | - struct ifaddrmsg ifa; |
1203 | - char buf[256]; |
1204 | - } req; |
1205 | - char *d = NULL; |
1206 | - char *l = NULL; |
1207 | - char *lcl_arg = NULL; |
1208 | - char *valid_lftp = NULL; |
1209 | - char *preferred_lftp = NULL; |
1210 | - inet_prefix lcl; |
1211 | - inet_prefix peer; |
1212 | - int local_len = 0; |
1213 | - int peer_len = 0; |
1214 | - int brd_len = 0; |
1215 | - int any_len = 0; |
1216 | - int scoped = 0; |
1217 | - __u32 preferred_lft = INFINITY_LIFE_TIME; |
1218 | - __u32 valid_lft = INFINITY_LIFE_TIME; |
1219 | - struct ifa_cacheinfo cinfo; |
1220 | - |
1221 | - memset(&req, 0, sizeof(req)); |
1222 | - |
1223 | - req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)); |
1224 | - req.n.nlmsg_flags = NLM_F_REQUEST | flags; |
1225 | - req.n.nlmsg_type = cmd; |
1226 | - req.ifa.ifa_family = preferred_family; |
1227 | - |
1228 | - while (argc > 0) { |
1229 | - if (strcmp(*argv, "peer") == 0 || |
1230 | - strcmp(*argv, "remote") == 0) { |
1231 | - NEXT_ARG(); |
1232 | - |
1233 | - if (peer_len) |
1234 | - duparg("peer", *argv); |
1235 | - get_prefix(&peer, *argv, req.ifa.ifa_family); |
1236 | - peer_len = peer.bytelen; |
1237 | - if (req.ifa.ifa_family == AF_UNSPEC) |
1238 | - req.ifa.ifa_family = peer.family; |
1239 | - addattr_l(&req.n, sizeof(req), IFA_ADDRESS, &peer.data, peer.bytelen); |
1240 | - req.ifa.ifa_prefixlen = peer.bitlen; |
1241 | - } else if (matches(*argv, "broadcast") == 0 || |
1242 | - strcmp(*argv, "brd") == 0) { |
1243 | - inet_prefix addr; |
1244 | - NEXT_ARG(); |
1245 | - if (brd_len) |
1246 | - duparg("broadcast", *argv); |
1247 | - if (strcmp(*argv, "+") == 0) |
1248 | - brd_len = -1; |
1249 | - else if (strcmp(*argv, "-") == 0) |
1250 | - brd_len = -2; |
1251 | - else { |
1252 | - get_addr(&addr, *argv, req.ifa.ifa_family); |
1253 | - if (req.ifa.ifa_family == AF_UNSPEC) |
1254 | - req.ifa.ifa_family = addr.family; |
1255 | - addattr_l(&req.n, sizeof(req), IFA_BROADCAST, &addr.data, addr.bytelen); |
1256 | - brd_len = addr.bytelen; |
1257 | - } |
1258 | - } else if (strcmp(*argv, "anycast") == 0) { |
1259 | - inet_prefix addr; |
1260 | - NEXT_ARG(); |
1261 | - if (any_len) |
1262 | - duparg("anycast", *argv); |
1263 | - get_addr(&addr, *argv, req.ifa.ifa_family); |
1264 | - if (req.ifa.ifa_family == AF_UNSPEC) |
1265 | - req.ifa.ifa_family = addr.family; |
1266 | - addattr_l(&req.n, sizeof(req), IFA_ANYCAST, &addr.data, addr.bytelen); |
1267 | - any_len = addr.bytelen; |
1268 | - } else if (strcmp(*argv, "scope") == 0) { |
1269 | - unsigned scope = 0; |
1270 | - NEXT_ARG(); |
1271 | - if (rtnl_rtscope_a2n(&scope, *argv)) |
1272 | - invarg("invalid scope value.", *argv); |
1273 | - req.ifa.ifa_scope = scope; |
1274 | - scoped = 1; |
1275 | - } else if (strcmp(*argv, "dev") == 0) { |
1276 | - NEXT_ARG(); |
1277 | - d = *argv; |
1278 | - } else if (strcmp(*argv, "label") == 0) { |
1279 | - NEXT_ARG(); |
1280 | - l = *argv; |
1281 | - addattr_l(&req.n, sizeof(req), IFA_LABEL, l, strlen(l)+1); |
1282 | - } else if (matches(*argv, "valid_lft") == 0) { |
1283 | - if (valid_lftp) |
1284 | - duparg("valid_lft", *argv); |
1285 | - NEXT_ARG(); |
1286 | - valid_lftp = *argv; |
1287 | - if (set_lifetime(&valid_lft, *argv)) |
1288 | - invarg("valid_lft value", *argv); |
1289 | - } else if (matches(*argv, "preferred_lft") == 0) { |
1290 | - if (preferred_lftp) |
1291 | - duparg("preferred_lft", *argv); |
1292 | - NEXT_ARG(); |
1293 | - preferred_lftp = *argv; |
1294 | - if (set_lifetime(&preferred_lft, *argv)) |
1295 | - invarg("preferred_lft value", *argv); |
1296 | - } else if (strcmp(*argv, "home") == 0) { |
1297 | - req.ifa.ifa_flags |= IFA_F_HOMEADDRESS; |
1298 | - } else if (strcmp(*argv, "nodad") == 0) { |
1299 | - req.ifa.ifa_flags |= IFA_F_NODAD; |
1300 | - } else { |
1301 | - if (strcmp(*argv, "local") == 0) { |
1302 | - NEXT_ARG(); |
1303 | - } |
1304 | - if (matches(*argv, "help") == 0) |
1305 | - usage(); |
1306 | - if (local_len) |
1307 | - duparg2("local", *argv); |
1308 | - lcl_arg = *argv; |
1309 | - get_prefix(&lcl, *argv, req.ifa.ifa_family); |
1310 | - if (req.ifa.ifa_family == AF_UNSPEC) |
1311 | - req.ifa.ifa_family = lcl.family; |
1312 | - addattr_l(&req.n, sizeof(req), IFA_LOCAL, &lcl.data, lcl.bytelen); |
1313 | - local_len = lcl.bytelen; |
1314 | - } |
1315 | - argc--; argv++; |
1316 | - } |
1317 | - if (d == NULL) { |
1318 | - fprintf(stderr, "Not enough information: \"dev\" argument is required.\n"); |
1319 | - return -1; |
1320 | - } |
1321 | - if (l && matches(d, l) != 0) { |
1322 | - fprintf(stderr, "\"dev\" (%s) must match \"label\" (%s).\n", d, l); |
1323 | - return -1; |
1324 | - } |
1325 | - |
1326 | - if (peer_len == 0 && local_len) { |
1327 | - if (cmd == RTM_DELADDR && lcl.family == AF_INET && !(lcl.flags & PREFIXLEN_SPECIFIED)) { |
1328 | - fprintf(stderr, |
1329 | - "Warning: Executing wildcard deletion to stay compatible with old scripts.\n" \ |
1330 | - " Explicitly specify the prefix length (%s/%d) to avoid this warning.\n" \ |
1331 | - " This special behaviour is likely to disappear in further releases,\n" \ |
1332 | - " fix your scripts!\n", lcl_arg, local_len*8); |
1333 | - } else { |
1334 | - peer = lcl; |
1335 | - addattr_l(&req.n, sizeof(req), IFA_ADDRESS, &lcl.data, lcl.bytelen); |
1336 | - } |
1337 | - } |
1338 | - if (req.ifa.ifa_prefixlen == 0) |
1339 | - req.ifa.ifa_prefixlen = lcl.bitlen; |
1340 | - |
1341 | - if (brd_len < 0 && cmd != RTM_DELADDR) { |
1342 | - inet_prefix brd; |
1343 | - int i; |
1344 | - if (req.ifa.ifa_family != AF_INET) { |
1345 | - fprintf(stderr, "Broadcast can be set only for IPv4 addresses\n"); |
1346 | - return -1; |
1347 | - } |
1348 | - brd = peer; |
1349 | - if (brd.bitlen <= 30) { |
1350 | - for (i=31; i>=brd.bitlen; i--) { |
1351 | - if (brd_len == -1) |
1352 | - brd.data[0] |= htonl(1<<(31-i)); |
1353 | - else |
1354 | - brd.data[0] &= ~htonl(1<<(31-i)); |
1355 | - } |
1356 | - addattr_l(&req.n, sizeof(req), IFA_BROADCAST, &brd.data, brd.bytelen); |
1357 | - brd_len = brd.bytelen; |
1358 | - } |
1359 | - } |
1360 | - if (!scoped && cmd != RTM_DELADDR) |
1361 | - req.ifa.ifa_scope = default_scope(&lcl); |
1362 | - |
1363 | - ll_init_map(&rth); |
1364 | - |
1365 | - if ((req.ifa.ifa_index = ll_name_to_index(d)) == 0) { |
1366 | - fprintf(stderr, "Cannot find device \"%s\"\n", d); |
1367 | - return -1; |
1368 | - } |
1369 | - |
1370 | - if (valid_lftp || preferred_lftp) { |
1371 | - if (!valid_lft) { |
1372 | - fprintf(stderr, "valid_lft is zero\n"); |
1373 | - return -1; |
1374 | - } |
1375 | - if (valid_lft < preferred_lft) { |
1376 | - fprintf(stderr, "preferred_lft is greater than valid_lft\n"); |
1377 | - return -1; |
1378 | - } |
1379 | - |
1380 | - memset(&cinfo, 0, sizeof(cinfo)); |
1381 | - cinfo.ifa_prefered = preferred_lft; |
1382 | - cinfo.ifa_valid = valid_lft; |
1383 | - addattr_l(&req.n, sizeof(req), IFA_CACHEINFO, &cinfo, |
1384 | - sizeof(cinfo)); |
1385 | - } |
1386 | - |
1387 | - if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0) |
1388 | - return -2; |
1389 | - |
1390 | - return 0; |
1391 | -} |
1392 | - |
1393 | -int do_ipaddr(int argc, char **argv) |
1394 | -{ |
1395 | - if (argc < 1) |
1396 | - return ipaddr_list_flush_or_save(0, NULL, IPADD_LIST); |
1397 | - if (matches(*argv, "add") == 0) |
1398 | - return ipaddr_modify(RTM_NEWADDR, NLM_F_CREATE|NLM_F_EXCL, argc-1, argv+1); |
1399 | - if (matches(*argv, "change") == 0 || |
1400 | - strcmp(*argv, "chg") == 0) |
1401 | - return ipaddr_modify(RTM_NEWADDR, NLM_F_REPLACE, argc-1, argv+1); |
1402 | - if (matches(*argv, "replace") == 0) |
1403 | - return ipaddr_modify(RTM_NEWADDR, NLM_F_CREATE|NLM_F_REPLACE, argc-1, argv+1); |
1404 | - if (matches(*argv, "delete") == 0) |
1405 | - return ipaddr_modify(RTM_DELADDR, 0, argc-1, argv+1); |
1406 | - if (matches(*argv, "list") == 0 || matches(*argv, "show") == 0 |
1407 | - || matches(*argv, "lst") == 0) |
1408 | - return ipaddr_list_flush_or_save(argc-1, argv+1, IPADD_LIST); |
1409 | - if (matches(*argv, "flush") == 0) |
1410 | - return ipaddr_list_flush_or_save(argc-1, argv+1, IPADD_FLUSH); |
1411 | - if (matches(*argv, "save") == 0) |
1412 | - return ipaddr_list_flush_or_save(argc-1, argv+1, IPADD_SAVE); |
1413 | - if (matches(*argv, "showdump") == 0) |
1414 | - return ipaddr_showdump(); |
1415 | - if (matches(*argv, "restore") == 0) |
1416 | - return ipaddr_restore(); |
1417 | - if (matches(*argv, "help") == 0) |
1418 | - usage(); |
1419 | - fprintf(stderr, "Command \"%s\" is unknown, try \"ip addr help\".\n", *argv); |
1420 | - exit(-1); |
1421 | -} |
1422 | - |
1423 | |
1424 | === modified file '.pc/applied-patches' |
1425 | --- .pc/applied-patches 2012-11-09 15:10:54 +0000 |
1426 | +++ .pc/applied-patches 2012-12-02 21:17:20 +0000 |
1427 | @@ -1,4 +1,4 @@ |
1428 | moo.diff |
1429 | txtdocs.diff |
1430 | cross.diff |
1431 | -7f747fd9377b8538adeba7332d25905ba08ac156.diff |
1432 | +0001-iproute2-List-interfaces-without-net-address-by-defa.patch |
1433 | |
1434 | === modified file 'debian/changelog' |
1435 | --- debian/changelog 2012-11-09 21:40:50 +0000 |
1436 | +++ debian/changelog 2012-12-02 21:17:20 +0000 |
1437 | @@ -1,3 +1,28 @@ |
1438 | +iproute (20121001-2ubuntu1) raring; urgency=low |
1439 | + |
1440 | + * Merge from Debian experimental. Remaining changes: |
1441 | + - debian/patches/cross.diff: Add cross-building support. |
1442 | + * Dropped changes: |
1443 | + - Cherry pick from git (done in 0001-iproute...patch in Debian). |
1444 | + |
1445 | + -- Logan Rosen <logatronico@gmail.com> Sun, 02 Dec 2012 16:11:13 -0500 |
1446 | + |
1447 | +iproute (20121001-2) experimental; urgency=low |
1448 | + |
1449 | + * Generate recommends for optional module dependencies |
1450 | + This makes the optional module dependency on libxtables more |
1451 | + visible, to hopefully get iproute rebuilt whenever libxtables |
1452 | + bumps soname. |
1453 | + Thanks to iptables maintainer for splitting libxtables9 into |
1454 | + a separate package in version 1.4.16.3-2. |
1455 | + * 0001-iproute2-List-interfaces-without-net-address-by-defa.patch: |
1456 | + List interfaces without net address by default. |
1457 | + This fixes regression in iproute2-3.5.1 when `ip addr show' skipped |
1458 | + interfaces without network layer address. |
1459 | + Patch from upstream (git 7f747fd9377b8538ad). |
1460 | + |
1461 | + -- Andreas Henriksson <andreas@fatal.se> Fri, 09 Nov 2012 15:49:24 +0100 |
1462 | + |
1463 | iproute (20121001-1ubuntu1) raring; urgency=low |
1464 | |
1465 | * Merge from Debian experimental. Remaining changes: (LP: #1077110) |
1466 | |
1467 | === modified file 'debian/control' |
1468 | --- debian/control 2012-06-25 14:47:02 +0000 |
1469 | +++ debian/control 2012-12-02 21:17:20 +0000 |
1470 | @@ -27,7 +27,7 @@ |
1471 | Provides: arpd |
1472 | Conflicts: arpd |
1473 | Depends: ${shlibs:Depends}, ${misc:Depends} |
1474 | -Recommends: libatm1 |
1475 | +Recommends: ${ipmods:Recommends} |
1476 | Suggests: iproute-doc |
1477 | Multi-Arch: foreign |
1478 | Description: networking and traffic control tools |
1479 | |
1480 | === added file 'debian/patches/0001-iproute2-List-interfaces-without-net-address-by-defa.patch' |
1481 | --- debian/patches/0001-iproute2-List-interfaces-without-net-address-by-defa.patch 1970-01-01 00:00:00 +0000 |
1482 | +++ debian/patches/0001-iproute2-List-interfaces-without-net-address-by-defa.patch 2012-12-02 21:17:20 +0000 |
1483 | @@ -0,0 +1,86 @@ |
1484 | +From 7f747fd9377b8538adeba7332d25905ba08ac156 Mon Sep 17 00:00:00 2001 |
1485 | +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com> |
1486 | +Date: Wed, 3 Oct 2012 16:42:41 +0200 |
1487 | +Subject: [PATCH] iproute2: List interfaces without net address by default |
1488 | +MIME-Version: 1.0 |
1489 | +Content-Type: text/plain; charset=UTF-8 |
1490 | +Content-Transfer-Encoding: 8bit |
1491 | + |
1492 | +This fixes regression in iproute2-3.5.1 when `ip addr show' skipped |
1493 | +interfaces without network layer address. |
1494 | + |
1495 | +Wrong output: |
1496 | +1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN |
1497 | + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 |
1498 | + inet 127.0.0.1/8 scope host lo |
1499 | + inet6 ::1/128 scope host |
1500 | + valid_lft forever preferred_lft forever |
1501 | +2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 |
1502 | + link/ether 00:50:54:00:0f:03 brd ff:ff:ff:ff:ff:ff |
1503 | + inet 10.34.25.198/23 brd 10.34.25.255 scope global eth0 |
1504 | + inet6 2620:52:0:2219:250:54ff:fe00:f03/64 scope global dynamic |
1505 | + valid_lft 2591919sec preferred_lft 604719sec |
1506 | + inet6 fe80::250:54ff:fe00:f03/64 scope link |
1507 | + valid_lft forever preferred_lft forever |
1508 | + |
1509 | +Expected output: |
1510 | +1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN |
1511 | + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 |
1512 | + inet 127.0.0.1/8 scope host lo |
1513 | + inet6 ::1/128 scope host |
1514 | + valid_lft forever preferred_lft forever |
1515 | +2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 |
1516 | + link/ether 00:50:54:00:0f:03 brd ff:ff:ff:ff:ff:ff |
1517 | + inet 10.34.25.198/23 brd 10.34.25.255 scope global eth0 |
1518 | + inet6 2620:52:0:2219:250:54ff:fe00:f03/64 scope global dynamic |
1519 | + valid_lft 2591896sec preferred_lft 604696sec |
1520 | + inet6 fe80::250:54ff:fe00:f03/64 scope link |
1521 | + valid_lft forever preferred_lft forever |
1522 | +5: veth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000 |
1523 | + link/ether 8a:ec:35:34:1f:a8 brd ff:ff:ff:ff:ff:ff |
1524 | +6: veth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000 |
1525 | + link/ether 2e:97:ef:77:40:82 brd ff:ff:ff:ff:ff:ff |
1526 | + |
1527 | +Signed-off-by: Petr Písař <ppisar@redhat.com> |
1528 | +--- |
1529 | + ip/ipaddress.c | 10 ++++++++-- |
1530 | + 1 file changed, 8 insertions(+), 2 deletions(-) |
1531 | + |
1532 | +diff --git a/ip/ipaddress.c b/ip/ipaddress.c |
1533 | +index 6c11ce4..5498f46 100644 |
1534 | +--- a/ip/ipaddress.c |
1535 | ++++ b/ip/ipaddress.c |
1536 | +@@ -884,6 +884,7 @@ static void ipaddr_filter(struct nlmsg_chain *linfo, struct nlmsg_chain *ainfo) |
1537 | + lp = &linfo->head; |
1538 | + while ( (l = *lp) != NULL) { |
1539 | + int ok = 0; |
1540 | ++ int missing_net_address = 1; |
1541 | + struct ifinfomsg *ifi = NLMSG_DATA(&l->h); |
1542 | + struct nlmsg_list *a; |
1543 | + |
1544 | +@@ -891,8 +892,10 @@ static void ipaddr_filter(struct nlmsg_chain *linfo, struct nlmsg_chain *ainfo) |
1545 | + struct nlmsghdr *n = &a->h; |
1546 | + struct ifaddrmsg *ifa = NLMSG_DATA(n); |
1547 | + |
1548 | +- if (ifa->ifa_index != ifi->ifi_index || |
1549 | +- (filter.family && filter.family != ifa->ifa_family)) |
1550 | ++ if (ifa->ifa_index != ifi->ifi_index) |
1551 | ++ continue; |
1552 | ++ missing_net_address = 0; |
1553 | ++ if (filter.family && filter.family != ifa->ifa_family) |
1554 | + continue; |
1555 | + if ((filter.scope^ifa->ifa_scope)&filter.scopemask) |
1556 | + continue; |
1557 | +@@ -927,6 +930,9 @@ static void ipaddr_filter(struct nlmsg_chain *linfo, struct nlmsg_chain *ainfo) |
1558 | + ok = 1; |
1559 | + break; |
1560 | + } |
1561 | ++ if (missing_net_address && |
1562 | ++ (filter.family == AF_UNSPEC || filter.family == AF_PACKET)) |
1563 | ++ ok = 1; |
1564 | + if (!ok) { |
1565 | + *lp = l->next; |
1566 | + free(l); |
1567 | +-- |
1568 | +1.7.10.4 |
1569 | + |
1570 | |
1571 | === removed file 'debian/patches/7f747fd9377b8538adeba7332d25905ba08ac156.diff' |
1572 | --- debian/patches/7f747fd9377b8538adeba7332d25905ba08ac156.diff 2012-11-09 21:40:45 +0000 |
1573 | +++ debian/patches/7f747fd9377b8538adeba7332d25905ba08ac156.diff 1970-01-01 00:00:00 +0000 |
1574 | @@ -1,86 +0,0 @@ |
1575 | -From 7f747fd9377b8538adeba7332d25905ba08ac156 Mon Sep 17 00:00:00 2001 |
1576 | -From: =?utf8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com> |
1577 | -Date: Wed, 3 Oct 2012 16:42:41 +0200 |
1578 | -Subject: [PATCH 1/1] iproute2: List interfaces without net address by default |
1579 | -MIME-Version: 1.0 |
1580 | -Content-Type: text/plain; charset=utf8 |
1581 | -Content-Transfer-Encoding: 8bit |
1582 | - |
1583 | -This fixes regression in iproute2-3.5.1 when `ip addr show' skipped |
1584 | -interfaces without network layer address. |
1585 | - |
1586 | -Wrong output: |
1587 | -1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN |
1588 | - link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 |
1589 | - inet 127.0.0.1/8 scope host lo |
1590 | - inet6 ::1/128 scope host |
1591 | - valid_lft forever preferred_lft forever |
1592 | -2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 |
1593 | - link/ether 00:50:54:00:0f:03 brd ff:ff:ff:ff:ff:ff |
1594 | - inet 10.34.25.198/23 brd 10.34.25.255 scope global eth0 |
1595 | - inet6 2620:52:0:2219:250:54ff:fe00:f03/64 scope global dynamic |
1596 | - valid_lft 2591919sec preferred_lft 604719sec |
1597 | - inet6 fe80::250:54ff:fe00:f03/64 scope link |
1598 | - valid_lft forever preferred_lft forever |
1599 | - |
1600 | -Expected output: |
1601 | -1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN |
1602 | - link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 |
1603 | - inet 127.0.0.1/8 scope host lo |
1604 | - inet6 ::1/128 scope host |
1605 | - valid_lft forever preferred_lft forever |
1606 | -2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 |
1607 | - link/ether 00:50:54:00:0f:03 brd ff:ff:ff:ff:ff:ff |
1608 | - inet 10.34.25.198/23 brd 10.34.25.255 scope global eth0 |
1609 | - inet6 2620:52:0:2219:250:54ff:fe00:f03/64 scope global dynamic |
1610 | - valid_lft 2591896sec preferred_lft 604696sec |
1611 | - inet6 fe80::250:54ff:fe00:f03/64 scope link |
1612 | - valid_lft forever preferred_lft forever |
1613 | -5: veth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000 |
1614 | - link/ether 8a:ec:35:34:1f:a8 brd ff:ff:ff:ff:ff:ff |
1615 | -6: veth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000 |
1616 | - link/ether 2e:97:ef:77:40:82 brd ff:ff:ff:ff:ff:ff |
1617 | - |
1618 | -Signed-off-by: Petr PÃsaÅ <ppisar@redhat.com> |
1619 | ---- |
1620 | - ip/ipaddress.c | 10 ++++++++-- |
1621 | - 1 files changed, 8 insertions(+), 2 deletions(-) |
1622 | - |
1623 | -diff --git a/ip/ipaddress.c b/ip/ipaddress.c |
1624 | -index 6c11ce4..5498f46 100644 |
1625 | ---- a/ip/ipaddress.c |
1626 | -+++ b/ip/ipaddress.c |
1627 | -@@ -884,6 +884,7 @@ static void ipaddr_filter(struct nlmsg_chain *linfo, struct nlmsg_chain *ainfo) |
1628 | - lp = &linfo->head; |
1629 | - while ( (l = *lp) != NULL) { |
1630 | - int ok = 0; |
1631 | -+ int missing_net_address = 1; |
1632 | - struct ifinfomsg *ifi = NLMSG_DATA(&l->h); |
1633 | - struct nlmsg_list *a; |
1634 | - |
1635 | -@@ -891,8 +892,10 @@ static void ipaddr_filter(struct nlmsg_chain *linfo, struct nlmsg_chain *ainfo) |
1636 | - struct nlmsghdr *n = &a->h; |
1637 | - struct ifaddrmsg *ifa = NLMSG_DATA(n); |
1638 | - |
1639 | -- if (ifa->ifa_index != ifi->ifi_index || |
1640 | -- (filter.family && filter.family != ifa->ifa_family)) |
1641 | -+ if (ifa->ifa_index != ifi->ifi_index) |
1642 | -+ continue; |
1643 | -+ missing_net_address = 0; |
1644 | -+ if (filter.family && filter.family != ifa->ifa_family) |
1645 | - continue; |
1646 | - if ((filter.scope^ifa->ifa_scope)&filter.scopemask) |
1647 | - continue; |
1648 | -@@ -927,6 +930,9 @@ static void ipaddr_filter(struct nlmsg_chain *linfo, struct nlmsg_chain *ainfo) |
1649 | - ok = 1; |
1650 | - break; |
1651 | - } |
1652 | -+ if (missing_net_address && |
1653 | -+ (filter.family == AF_UNSPEC || filter.family == AF_PACKET)) |
1654 | -+ ok = 1; |
1655 | - if (!ok) { |
1656 | - *lp = l->next; |
1657 | - free(l); |
1658 | --- |
1659 | -1.7.6.5 |
1660 | - |
1661 | |
1662 | === modified file 'debian/patches/series' |
1663 | --- debian/patches/series 2012-11-09 21:40:45 +0000 |
1664 | +++ debian/patches/series 2012-12-02 21:17:20 +0000 |
1665 | @@ -1,4 +1,4 @@ |
1666 | moo.diff |
1667 | txtdocs.diff |
1668 | cross.diff |
1669 | -7f747fd9377b8538adeba7332d25905ba08ac156.diff |
1670 | +0001-iproute2-List-interfaces-without-net-address-by-defa.patch |
1671 | |
1672 | === modified file 'debian/rules' |
1673 | --- debian/rules 2012-06-25 14:47:02 +0000 |
1674 | +++ debian/rules 2012-12-02 21:17:20 +0000 |
1675 | @@ -22,7 +22,7 @@ |
1676 | |
1677 | override_dh_shlibdeps: |
1678 | dh_shlibdeps -a -Xq_atm.so -Xm_xt.so -Xm_ipt.so |
1679 | - |
1680 | + dh_shlibdeps -a -- -pipmods -dRecommends -e debian/iproute/usr/lib/tc/m_xt.so -e debian/iproute/usr/lib/tc/q_atm.so -xlibc6 |
1681 | |
1682 | override_dh_auto_configure: |
1683 | $(CROSS) dh_auto_configure |
Good work.