From f1baa204dc0f7edabb8e23330271e6fdc26df7e2 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Mon, 11 Jul 2016 17:51:55 +0200 Subject: [PATCH] mrt: skip MRT errors instead of just dying When trying to inject a full view from the router views project, it seems that some entries have an unexpected flag (transitive flag missing). Just skip those entries instead of dying. --- gobgp/cmd/common.go | 6 +++++- gobgp/cmd/mrt.go | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gobgp/cmd/common.go b/gobgp/cmd/common.go index 5aaadaf8..9a4b8164 100644 --- a/gobgp/cmd/common.go +++ b/gobgp/cmd/common.go @@ -477,7 +477,7 @@ func checkAddressFamily(def bgp.RouteFamily) (bgp.RouteFamily, error) { return rf, e } -func exitWithError(err error) { +func printError(err error) { if globalOpts.Json { j, _ := json.Marshal(struct { Error string `json:"error"` @@ -486,5 +486,9 @@ func exitWithError(err error) { } else { fmt.Println(err) } +} + +func exitWithError(err error) { + printError(err) os.Exit(1) } diff --git a/gobgp/cmd/mrt.go b/gobgp/cmd/mrt.go index c3ecf0ed..f9287f77 100644 --- a/gobgp/cmd/mrt.go +++ b/gobgp/cmd/mrt.go @@ -73,7 +73,8 @@ func injectMrt(r string, filename string, count int, skip int) error { msg, err := mrt.ParseMRTBody(h, buf) if err != nil { - exitWithError(fmt.Errorf("failed to parse: %s", err)) + printError(fmt.Errorf("failed to parse: %s", err)) + continue } if globalOpts.Debug {