-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only add no bgp enforce-first-as on frr >= 10 (#194)
- Loading branch information
Showing
6 changed files
with
70 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package frr | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
"strings" | ||
|
||
"github.com/Masterminds/semver/v3" | ||
) | ||
|
||
func DetectVersion() (*semver.Version, error) { | ||
|
||
vtysh, err := exec.LookPath("vtysh") | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to detect path to vtysh: %w", err) | ||
} | ||
// $ vtysh -c "show version"|grep FRRouting | ||
// FRRouting 10.2.1 (shoot--pz9cjf--mwen-fel-firewall-dcedd) on Linux(6.6.60-060660-generic). | ||
c := exec.Command(vtysh, "-c", "show version") | ||
out, err := c.CombinedOutput() | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to detect frr version with dpkg: %w", err) | ||
} | ||
|
||
var frrVersion string | ||
for _, line := range strings.Split(string(out), "\n") { | ||
if !strings.Contains(line, "FRRouting") { | ||
continue | ||
} | ||
|
||
fields := strings.Fields(line) | ||
if len(fields) < 2 { | ||
continue | ||
} | ||
|
||
frrVersion = fields[1] | ||
break | ||
} | ||
if frrVersion == "" { | ||
return nil, fmt.Errorf("unable to detect frr version") | ||
} | ||
|
||
ver, err := semver.NewVersion(frrVersion) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to parse frr version to semver: %w", err) | ||
} | ||
return ver, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters