line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Eixo::Zone::Network::Ctl; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
2457
|
use strict; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
81
|
|
4
|
3
|
|
|
3
|
|
1983
|
use parent qw(Eixo::Zone::Ctl); |
|
3
|
|
|
|
|
817
|
|
|
3
|
|
|
|
|
17
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my $CMD_IP; |
7
|
|
|
|
|
|
|
my $CMD_BRCTL; |
8
|
|
|
|
|
|
|
my $CMD_ROUTE; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN{ |
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
2471385
|
$CMD_IP = `env which ip`; chomp($CMD_IP); |
|
3
|
|
|
|
|
67
|
|
13
|
|
|
|
|
|
|
|
14
|
3
|
50
|
|
|
|
78
|
unless($CMD_IP){ |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
0
|
die(__PACKAGE__ . ':: not ip command found'); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
23896
|
$CMD_BRCTL = `env which brctl`; chomp($CMD_BRCTL); |
|
3
|
|
|
|
|
62
|
|
20
|
|
|
|
|
|
|
|
21
|
3
|
50
|
|
|
|
101
|
unless($CMD_BRCTL){ |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
783
|
die(__PACKAGE__ . ':: not brctl command found'); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
$CMD_ROUTE = `env which route`; chomp($CMD_ROUTE); |
|
0
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
unless($CMD_ROUTE){ |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
die(__PACKAGE__ . ':: not route command found'); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
#========================= |
37
|
|
|
|
|
|
|
# Links |
38
|
|
|
|
|
|
|
#========================= |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub link_up_ns{ |
41
|
|
|
|
|
|
|
my ($self, $name, $ns) = @_; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my @cmd = $self->link_up($name,'--ns'); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$self->ns_exec($ns, @cmd); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub link_up{ |
49
|
|
|
|
|
|
|
my ($self, $name) = @_; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $in_ns = grep {$_ eq '--ns'} @_; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my @cmd = ( |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$CMD_IP, |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
'link', |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
'set', |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
'dev', |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$name, |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
'up' |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
return @cmd if($in_ns); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$self->runSysWait(@cmd); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub link_addr_ns{ |
75
|
|
|
|
|
|
|
my ($self, $name, $net, $ns) = @_; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my @cmd = $self->link_addr($name, $net, '--ns'); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$self->ns_exec($ns, @cmd); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub link_addr{ |
83
|
|
|
|
|
|
|
my ($self, $name, $net) = @_; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $in_ns = grep {$_ eq '--ns'} @_; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my @cmd = ( |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
$CMD_IP, |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
'addr', |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
'add', |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$net, |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
'dev', |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$name, |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
return @cmd if($in_ns); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$_[0]->runSysWait(@cmd); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub link_create{ |
109
|
|
|
|
|
|
|
my ($self, $name_a, $name_b, $type) = @_; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
$type = $type || 'veth'; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
$_[0]->runSysWait( |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$CMD_IP, |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
'link', |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
'add', |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
$name_a, |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
'type', |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
$type, |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
'peer', |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
'name', |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
$name_b |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub link_delete{ |
137
|
|
|
|
|
|
|
my ($self, $name) = @_; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$_[0]->runSysWait( |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
$CMD_IP, |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
'link', |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
'delete', |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
$name |
148
|
|
|
|
|
|
|
); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub link_exists{ |
152
|
|
|
|
|
|
|
my ($self, $name) = @_; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
grep { $_->{name} eq $name} $self->link_list; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub link_list{ |
159
|
|
|
|
|
|
|
my ($self) = @_; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
my $info = $_[0]->runSysWaitEcho($CMD_IP, 'link', 'list'); |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
map { |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
my @parts = map { $_ =~ s/\:?\s*$//; $_ } split(/\s+/, $_); |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
{ |
168
|
|
|
|
|
|
|
dev => $parts[0], |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
name=>$parts[1] |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
} grep { $_ =~ /^\s*\d+\:/ } split(/\n/, $info); |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub link_setns{ |
178
|
|
|
|
|
|
|
my ($self, $link, $namespace) = @_; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
$self->runSysWait( |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
$CMD_IP, |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
'link', |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
'set', |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
$link, |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
'netns', |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
$namespace |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
); |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
#========================= |
201
|
|
|
|
|
|
|
# Namespace |
202
|
|
|
|
|
|
|
#========================= |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub ns_create{ |
205
|
|
|
|
|
|
|
my ($self, $name) = @_; |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
$_[0]->runSysWait($CMD_IP, 'netns', 'add', $name); |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub ns_list{ |
211
|
|
|
|
|
|
|
my ($self) = @_; |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
$_[0]->runSysWaitEcho($CMD_IP, 'netns', 'list'); |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub ns_delete{ |
217
|
|
|
|
|
|
|
my ($self, $name) = @_; |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
$_[0]->runSysWait($CMD_IP, 'netns', 'delete', $name); |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub ns_exec{ |
223
|
|
|
|
|
|
|
my ($self, $namespace, @cmd) = @_; |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
my $method = "runSysWait"; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
if(grep { $_ eq '--with_echo'} @_){ |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
@cmd = grep {$_ ne "--with_echo"} @cmd; |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
$method = "runSysWaitEcho"; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
$_[0]->$method( |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
$CMD_IP, |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
'netns', |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
'exec', |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
$namespace, |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
@cmd |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
); |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
sub ns_exists{ |
250
|
|
|
|
|
|
|
my ($self, $namespace) = @_; |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
grep { |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
$_ eq $namespace |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
} split(/\n/, $self->ns_list); |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
} |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
#============================================== |
261
|
|
|
|
|
|
|
# Bridge utilities |
262
|
|
|
|
|
|
|
#============================================== |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
sub bridge_create{ |
265
|
|
|
|
|
|
|
my ($self, $name) = @_; |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
my $in_ns = grep {$_ eq '--ns'} @_; |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
my @cmd = ( |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
$CMD_BRCTL, |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
'addbr', |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
$name |
276
|
|
|
|
|
|
|
); |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
return @cmd if($in_ns); |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
$self->runSysWait(@cmd); |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
sub bridge_create_ns{ |
284
|
|
|
|
|
|
|
my ($self, $name, $ns) = @_; |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
my @cmd = $self->bridge_create($name,'--ns'); |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
$self->ns_exec($ns, @cmd); |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
sub bridge_rm{ |
292
|
|
|
|
|
|
|
my ($self, $name) = @_; |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
my $in_ns = grep {$_ eq '--ns'} @_; |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
my @cmd = ( |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
$CMD_BRCTL, |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
'delbr', |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
$name |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
); |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
return @cmd if($in_ns); |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
$self->runSysWait(@cmd); |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
sub bridge_rm_ns{ |
312
|
|
|
|
|
|
|
my ($self, $name, $ns) = @_; |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
my @cmd = $self->bridge_rm($name,'--ns'); |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
$self->ns_exec($ns, @cmd); |
317
|
|
|
|
|
|
|
} |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
sub bridge_addif{ |
320
|
|
|
|
|
|
|
my ($self, $name, $dev) = @_; |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
my $in_ns = grep {$_ eq '--ns'} @_; |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
my @cmd = ( |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
$CMD_BRCTL, |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
'addif', |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
$name, |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
$dev |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
); |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
return @cmd if($in_ns); |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
$self->runSysWait(@cmd); |
339
|
|
|
|
|
|
|
} |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
sub bridge_addif_ns{ |
342
|
|
|
|
|
|
|
my ($self, $name, $dev, $ns) = @_; |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
my @cmd = $self->bridge_addif($name, $dev, "--ns"); |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
$self->ns_exec(@cmd); |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
} |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
sub bridge_delif{ |
351
|
|
|
|
|
|
|
my ($self, $name, $dev) = @_; |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
$self->runSysWait( |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
$CMD_BRCTL, |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
'delif', |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
$name, |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
$dev |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
); |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
} |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
sub bridge_exists_ns{ |
368
|
|
|
|
|
|
|
my ($self, $name, $ns) = @_; |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
grep { |
371
|
|
|
|
|
|
|
$_->{name} eq $name; |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
} $self->bridge_list_ns($ns); |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
sub bridge_exists{ |
377
|
|
|
|
|
|
|
my ($self, $name) = @_; |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
grep { |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
$_->{name} eq $name; |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
} $self->bridge_list; |
384
|
|
|
|
|
|
|
} |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
sub bridge_list_ns{ |
387
|
|
|
|
|
|
|
my ($self, $ns) = @_; |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
$self->bridge_list($ns, "--ns"); |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
sub bridge_list{ |
393
|
|
|
|
|
|
|
my ($self) = @_; |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
my ($blank, @l); |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
if(grep {$_ eq '--ns'} @_){ |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
($blank, @l) = split(/\n/, $self->ns_exec($_[1], $CMD_BRCTL, "show", "--with_echo")); |
400
|
|
|
|
|
|
|
} |
401
|
|
|
|
|
|
|
else{ |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
($blank, @l) = split(/\n/, $self->runSysWaitEcho($CMD_BRCTL, 'show')); |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
} |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
my @bridges; |
409
|
|
|
|
|
|
|
my $i = -1; |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
foreach my $l (@l){ |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
if($l =~ /([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)?/){ |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
$bridges[++$i] = { |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
name=>$1, |
418
|
|
|
|
|
|
|
id=>$2, |
419
|
|
|
|
|
|
|
stp=>$3, |
420
|
|
|
|
|
|
|
interfaces=>$4 ? [$4] : [] |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
}; |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
} |
426
|
|
|
|
|
|
|
elsif($l =~ /^\s+([^\s]+)\s*$/){ |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
push @{$bridges[$i]->{interfaces}}, $1; |
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
} |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
@bridges; |
433
|
|
|
|
|
|
|
} |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
#========================= |
436
|
|
|
|
|
|
|
# Route |
437
|
|
|
|
|
|
|
#========================= |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
sub route_add{ |
440
|
|
|
|
|
|
|
my ($self, $destiny, $netmask, $dev) = @_; |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
my @args; |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
$destiny eq 'default' ? push @args, 'default' : push @args, '-net', $destiny; |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
$netmask ? push @args, 'netmask', $netmask : undef; |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
push @args, 'dev', $dev; |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
print join(" ", $CMD_ROUTE, 'add', @args, "\n"); |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
$self->runSysWait( |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
$CMD_ROUTE, |
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
'add', |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
@args |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
); |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
} |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
sub route_del{ |
465
|
|
|
|
|
|
|
my ($self, $destiny) = @_; |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
$self->runSysWait( |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
$CMD_ROUTE, |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
'del', |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
$destiny |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
); |
476
|
|
|
|
|
|
|
} |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
sub route_exists{ |
479
|
|
|
|
|
|
|
my ($self, $destiny) = @_; |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
map { |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
$_->{destiny} eq $destiny |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
} $self->route_show; |
486
|
|
|
|
|
|
|
} |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
sub route_show{ |
489
|
|
|
|
|
|
|
my ($self) = @_; |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
my ($blank, @l) = split(/\n/, $self->runSysWaitEcho($CMD_ROUTE)); |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
map { |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
my ($destiny, $gateway, $genmask, $index, $metric, $ref, $use, $dev) = |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
split(/\s+/, @l); |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
{ |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
destiny=>$destiny, |
502
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
gateway=>$gateway, |
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
genmask=>$genmask, |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
index=>$index, |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
metric=>$metric, |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
ref=>$ref, |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
use=> $use, |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
dev=>$dev |
516
|
|
|
|
|
|
|
} |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
} @l; |
519
|
|
|
|
|
|
|
} |
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
1; |