@@ -57,6 +57,10 @@ func injectMrt() error {
57
57
fmt .Println ("You should probably specify either --no-ipv4 or --no-ipv6 when overwriting nexthop, unless your dump contains only one type of routes" )
58
58
}
59
59
60
+ if mrtOpts .Best && mrtOpts .PeerASN != 0 {
61
+ fmt .Println ("--only-best has no effect when --peer-asn is specified" )
62
+ }
63
+
60
64
var idx int64
61
65
if mrtOpts .QueueSize < 1 {
62
66
return fmt .Errorf ("specified queue size is smaller than 1, refusing to run with unbounded memory usage" )
@@ -132,6 +136,10 @@ func injectMrt() error {
132
136
}
133
137
//t := time.Unix(int64(e.OriginatedTime), 0)
134
138
139
+ if mrtOpts .PeerASN != 0 && peers [e .PeerIndex ].AS != mrtOpts .PeerASN {
140
+ continue
141
+ }
142
+
135
143
var attrs []bgp.PathAttributeInterface
136
144
switch subType {
137
145
case mrt .RIB_IPV4_UNICAST , mrt .RIB_IPV4_UNICAST_ADDPATH :
@@ -169,7 +177,7 @@ func injectMrt() error {
169
177
}
170
178
171
179
// TODO: calculate properly if necessary.
172
- if mrtOpts .Best {
180
+ if mrtOpts .Best && len ( paths ) > 0 {
173
181
paths = []* api.Path {paths [0 ]}
174
182
}
175
183
@@ -250,5 +258,6 @@ func newMrtCmd() *cobra.Command {
250
258
mrtCmd .PersistentFlags ().BoolVarP (& mrtOpts .SkipV6 , "no-ipv6" , "" , false , "Do not import IPv6 routes" )
251
259
mrtCmd .PersistentFlags ().IntVarP (& mrtOpts .QueueSize , "queue-size" , "" , 1 << 10 , "Maximum number of updates to keep queued" )
252
260
mrtCmd .PersistentFlags ().IPVarP (& mrtOpts .NextHop , "nexthop" , "" , nil , "Overwrite nexthop" )
261
+ mrtCmd .PersistentFlags ().Uint32VarP (& mrtOpts .PeerASN , "peer-asn" , "" , 0 , "Inject prefixes only from specified AS number" )
253
262
return mrtCmd
254
263
}
0 commit comments