summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVincent Bernat <vincent@bernat.im>2016-02-16 17:34:05 +0100
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-02-10 02:26:27 +0900
commitc8ded1216f973673061e3706fbfdf98a719ab378 (patch)
tree23f2f9714eaa529395685ed242209d3642cb1e24
parenta892882fe3769573cce8a88a3cbd5ef655131d41 (diff)
mrt: ability to skip entries when injecting
When we want to import a partial view from the same full view on two different routers, it can be useful to have a different view for each router, hence the ability to skip the first records. Signed-off-by: Vincent Bernat <vincent@bernat.im>
-rw-r--r--gobgp/cmd/mrt.go24
1 files changed, 17 insertions, 7 deletions
diff --git a/gobgp/cmd/mrt.go b/gobgp/cmd/mrt.go
index fa93b524..3c87ce46 100644
--- a/gobgp/cmd/mrt.go
+++ b/gobgp/cmd/mrt.go
@@ -189,7 +189,7 @@ func dumpRib(r string, remoteIP net.IP, args []string) error {
return nil
}
-func injectMrt(r string, filename string, count int) error {
+func injectMrt(r string, filename string, count int, skip int) error {
var resource api.Resource
switch r {
@@ -300,13 +300,15 @@ func injectMrt(r string, filename string, count int) error {
paths = append(paths, path)
}
- ch <- &api.ModPathsArguments{
- Resource: resource,
- Paths: paths,
+ if idx >= skip {
+ ch <- &api.ModPathsArguments{
+ Resource: resource,
+ Paths: paths,
+ }
}
idx += 1
- if idx == count {
+ if idx == count+skip {
break
}
}
@@ -387,11 +389,12 @@ func NewMrtCmd() *cobra.Command {
Use: CMD_GLOBAL,
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 1 {
- fmt.Println("usage: gobgp mrt inject global <filename> [<count>]")
+ fmt.Println("usage: gobgp mrt inject global <filename> [<count> [<skip>]]")
os.Exit(1)
}
filename := args[0]
count := -1
+ skip := 0
if len(args) > 1 {
var err error
count, err = strconv.Atoi(args[1])
@@ -399,8 +402,15 @@ func NewMrtCmd() *cobra.Command {
fmt.Println("invalid count value:", args[1])
os.Exit(1)
}
+ if len(args) > 2 {
+ skip, err = strconv.Atoi(args[2])
+ if err != nil {
+ fmt.Println("invalid skip value:", args[2])
+ os.Exit(1)
+ }
+ }
}
- err := injectMrt(CMD_GLOBAL, filename, count)
+ err := injectMrt(CMD_GLOBAL, filename, count, skip)
if err != nil {
fmt.Println(err)
os.Exit(1)