diff options
-rw-r--r-- | api/gobgp.pb.go | 5 | ||||
-rw-r--r-- | api/gobgp.proto | 5 | ||||
-rw-r--r-- | config/bgp_configs.go | 2 | ||||
-rw-r--r-- | docs/sources/filter-detail.md | 45 | ||||
-rw-r--r-- | docs/sources/filter.md | 8 | ||||
-rw-r--r-- | gobgp/policy.go | 12 | ||||
-rw-r--r-- | policy/policy.go | 32 | ||||
-rw-r--r-- | policy/policy_test.go | 43 | ||||
-rw-r--r-- | test/scenario_test/policy/policy_generator.go | 25 | ||||
-rw-r--r-- | tools/config/example_toml.go | 3 | ||||
-rw-r--r-- | tools/pyang_plugins/bgpyang2golang.py | 2 |
11 files changed, 73 insertions, 109 deletions
diff --git a/api/gobgp.pb.go b/api/gobgp.pb.go index 2dabd008..436f6119 100644 --- a/api/gobgp.pb.go +++ b/api/gobgp.pb.go @@ -1131,9 +1131,8 @@ func (m *Peer) GetInfo() *PeerInfo { } type Prefix struct { - Address string `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"` - MaskLength uint32 `protobuf:"varint,2,opt,name=mask_length" json:"mask_length,omitempty"` - MaskLengthRange string `protobuf:"bytes,3,opt,name=mask_length_range" json:"mask_length_range,omitempty"` + IpPrefix string `protobuf:"bytes,1,opt,name=ip_prefix" json:"ip_prefix,omitempty"` + MaskLengthRange string `protobuf:"bytes,2,opt,name=mask_length_range" json:"mask_length_range,omitempty"` } func (m *Prefix) Reset() { *m = Prefix{} } diff --git a/api/gobgp.proto b/api/gobgp.proto index 2f20a5b9..74c0b993 100644 --- a/api/gobgp.proto +++ b/api/gobgp.proto @@ -420,9 +420,8 @@ message Peer { } message Prefix { - string address = 1; - uint32 mask_length = 2; - string mask_length_range = 3; + string ip_prefix = 1; + string mask_length_range = 2; } message PrefixSet { diff --git a/config/bgp_configs.go b/config/bgp_configs.go index 24e89482..7530cd21 100644 --- a/config/bgp_configs.go +++ b/config/bgp_configs.go @@ -1566,7 +1566,7 @@ type NeighborSets struct { type Prefix struct { // original -> rpol:ip-prefix //rpol:ip-prefix's original type is inet:ip-prefix - IpPrefix net.IPNet + IpPrefix string // original -> rpol:masklength-range MasklengthRange string } diff --git a/docs/sources/filter-detail.md b/docs/sources/filter-detail.md index 792185c8..b096ed27 100644 --- a/docs/sources/filter-detail.md +++ b/docs/sources/filter-detail.md @@ -65,10 +65,8 @@ PrefixSets and NeighborSets section are prefix match part and neighbor match par [[DefinedSets.PrefixSets.PrefixSetList]] PrefixSetName = "ps1" [[DefinedSets.PrefixSets.PrefixSetList.PrefixList]] + IpPrefix = "10.33.0.0/16" MasklengthRange = "21..24" - [DefinedSets.PrefixSets.PrefixSetList.PrefixList.IpPrefix] - IP = "10.33.0.0 - Mask = [255, 255, 0, 0] # neighbor match part [DefinedSets.NeighborSets] @@ -85,12 +83,11 @@ PrefixSets and NeighborSets section are prefix match part and neighbor match par PrefixSetList has 3 elements. - | Element |Description | Example | Optional | - |-----------------|-------------------|------------|------------| - | PrefixSetName | name of PrefixSet | "10.33.0.0"| | - | IP | prefix address | "10.33.0.0"| | - | MASK | prefix length | 16 | | - | MasklengthRange | range of length | "21..24" | Yes | + | Element |Description | Example | Optional | + |-----------------|-------------------|---------------|------------| + | PrefixSetName | name of PrefixSet | "ps1" | | + | IpPrefix | prefix value | "10.33.0.0/16"| | + | MasklengthRange | range of length | "21..24" | Yes | ##### Examples @@ -102,11 +99,9 @@ PrefixSets and NeighborSets section are prefix match part and neighbor match par [DefinedSets.PrefixSets] [[DefinedSets.PrefixSets.PrefixSetList]] PrefixSetName = "ps1" - [[DefinedSets.PrefixSets.PrefixSetList.PrefixList]] + [[DefinedSets.PrefixSets.PrefixSetList.PrefixList]] + IpPrefix = "10.33.0.0/16" MasklengthRange = "21..24" - [DefinedSets.PrefixSets.PrefixSetList.PrefixList.IpPrefix] - IP = "10.33.0.0" - Mask = [255, 255, 0, 0] ``` - If you define a PrefixList that doesn't have MasklengthRange, it matches routes that have just 10.33.0.0/16 as NLRI. @@ -120,16 +115,12 @@ PrefixSets and NeighborSets section are prefix match part and neighbor match par [DefinedSets.PrefixSets] [[DefinedSets.PrefixSets.PrefixSetList]] PrefixSetName = "ps1" - [[DefinedSets.PrefixSets.PrefixSetList.PrefixList]] + [[DefinedSets.PrefixSets.PrefixSetList.PrefixList]] + IpPrefix = "10.33.0.0/16" MasklengthRange = "21..24" - [DefinedSets.PrefixSets.PrefixSetList.PrefixList.IpPrefix] - IP = "10.33.0.0" - Mask = [255, 255, 0, 0] - [[DefinedSets.PrefixSets.PrefixSetList.PrefixList]] + [[DefinedSets.PrefixSets.PrefixSetList.PrefixList]] + IpPrefix = "10.50.0.0/16" MasklengthRange = "21..24" - [DefinedSets.PrefixSets.PrefixSetList.PrefixList.IpPrefix] - IP = "10.50.0.0" - Mask = [255, 255, 0, 0] ``` - This prefix match checks if a route has 10.33.0.0/21 to 24 **or** 10.50.0.0/21 to 24. @@ -144,19 +135,15 @@ PrefixSets and NeighborSets section are prefix match part and neighbor match par # PrefixSetList [[DefinedSets.PrefixSets.PrefixSetList]] PrefixSetName = "ps1" - [[DefinedSets.PrefixSets.PrefixSetList.PrefixList]] + [[DefinedSets.PrefixSets.PrefixSetList.PrefixList]] + IpPrefix = "10.33.0.0/16" MasklengthRange = "21..24" - [DefinedSets.PrefixSets.PrefixSetList.PrefixList.IpPrefix] - IP = "10.33.0.0" - Mask = [255, 255, 0, 0] # another PrefixSetList [[DefinedSets.PrefixSets.PrefixSetList]] PrefixSetName = "ps2" - [[DefinedSets.PrefixSets.PrefixSetList.PrefixList]] + [[DefinedSets.PrefixSets.PrefixSetList.PrefixList]] + IpPrefix = "10.50.0.0/16" MasklengthRange = "21..24" - [DefinedSets.PrefixSets.PrefixSetList.PrefixList.IpPrefix] - IP = "10.50.0.0 - Mask = [255, 255, 0, 0] ``` ---- diff --git a/docs/sources/filter.md b/docs/sources/filter.md index 0cd23a37..3f64f500 100644 --- a/docs/sources/filter.md +++ b/docs/sources/filter.md @@ -69,13 +69,9 @@ define an import policy for neighbor 10.0.255.2 that drops [[DefinedSets.PrefixSets.PrefixSetList]] PrefixSetName = "ps2" [[DefinedSets.PrefixSets.PrefixSetList.PrefixList]] - [DefinedSets.PrefixSets.PrefixSetList.PrefixList.IpPrefix] - IP = "10.33.0.0 - Mask = [255, 255, 0, 0] + IpPrefix = "10.33.0.0/16" [[DefinedSets.PrefixSets.PrefixSetList.PrefixList]] - [DefinedSets.PrefixSets.PrefixSetList.PrefixList.IpPrefix] - IP = "10.50.0.0" - Mask = [255, 255, 0, 0] + IpPrefix = "10.50.0.0/16" [DefinedSets.NeighborSets] diff --git a/gobgp/policy.go b/gobgp/policy.go index 8c13863c..07c73ef1 100644 --- a/gobgp/policy.go +++ b/gobgp/policy.go @@ -41,8 +41,8 @@ func formatPolicyPrefix(head bool, indent int, psl []*api.PrefixSet) string { maxNameLen = len(ps.PrefixSetName) } for _, p := range ps.PrefixList { - if len(p.Address)+len(fmt.Sprint(p.MaskLength))+1 > maxPrefixLen { - maxPrefixLen = len(p.Address) + len(fmt.Sprint(p.MaskLength)) + 1 + if len(p.IpPrefix) > maxPrefixLen { + maxPrefixLen = len(p.IpPrefix) } if len(p.MaskLengthRange) > maxRangeLen { maxRangeLen = len(p.MaskLengthRange) @@ -68,7 +68,7 @@ func formatPolicyPrefix(head bool, indent int, psl []*api.PrefixSet) string { } for _, ps := range psl { for i, p := range ps.PrefixList { - prefix := fmt.Sprintf("%s/%d", p.Address, p.MaskLength) + prefix := fmt.Sprintf("%s", p.IpPrefix) if i == 0 { buff += fmt.Sprintf(format, ps.PrefixSetName, prefix, p.MaskLengthRange) } else { @@ -136,7 +136,7 @@ func showPolicyPrefix(args []string) error { } if globalOpts.Quiet { for _, p := range ps.PrefixList { - fmt.Printf("%s/%d %s\n", p.Address, p.MaskLength, p.MaskLengthRange) + fmt.Printf("%s %s\n", p.IpPrefix, p.MaskLengthRange) } return nil } @@ -150,10 +150,8 @@ func parsePrefixSet(eArgs []string) (*api.PrefixSet, error) { if e != nil { return nil, fmt.Errorf("invalid prefix: %s\nplease enter ipv4 or ipv6 format", eArgs[1]) } - mask, _ := ipNet.Mask.Size() prefix := &api.Prefix{ - Address: ipNet.IP.String(), - MaskLength: uint32(mask), + IpPrefix: eArgs[1], } if len(eArgs) == 3 { diff --git a/policy/policy.go b/policy/policy.go index afe2f1a8..0ea3d373 100644 --- a/policy/policy.go +++ b/policy/policy.go @@ -193,9 +193,7 @@ func NewPrefixCondition(matchPref config.MatchPrefixSet, defPrefixList []config. for _, ps := range defPrefixList { if ps.PrefixSetName == prefixSetName { for _, prefix := range ps.PrefixList { - addr := prefix.IpPrefix.IP - maskLength, _ := prefix.IpPrefix.Mask.Size() - prefix, e := NewPrefix(addr, uint8(maskLength), prefix.MasklengthRange) + prefix, e := NewPrefix(prefix.IpPrefix, prefix.MasklengthRange) if e != nil { log.WithFields(log.Fields{ "Topic": "Policy", @@ -1316,13 +1314,17 @@ type Prefix struct { MasklengthRange map[MaskLengthRangeType]uint8 } -func NewPrefix(addr net.IP, maskLen uint8, maskRange string) (Prefix, error) { +func NewPrefix(prefixStr string, maskRange string) (Prefix, error) { + p := Prefix{} mlr := make(map[MaskLengthRangeType]uint8) - p := Prefix{ - Address: addr, - Masklength: maskLen, - MasklengthRange: make(map[MaskLengthRangeType]uint8), + addr, ipPref, e := net.ParseCIDR(prefixStr) + + if e != nil { + return p, e } + maskLength, _ := ipPref.Mask.Size() + p.Address = addr + p.Masklength = uint8(maskLength) if ipv4Family := addr.To4(); ipv4Family != nil { p.AddressFamily, _ = bgp.GetRouteFamily("ipv4-unicast") @@ -1632,13 +1634,8 @@ func IndexOfPolicyDefinition(conPolicyList []config.PolicyDefinition, reqPolicy func PrefixSetToApiStruct(ps config.PrefixSet) *api.PrefixSet { resPrefixList := make([]*api.Prefix, 0) for _, p := range ps.PrefixList { - - addr := p.IpPrefix.IP - length, _ := p.IpPrefix.Mask.Size() - resPrefix := &api.Prefix{ - Address: addr.String(), - MaskLength: uint32(length), + IpPrefix: p.IpPrefix, MaskLengthRange: p.MasklengthRange, } resPrefixList = append(resPrefixList, resPrefix) @@ -1656,13 +1653,8 @@ func PrefixSetToConfigStruct(reqPrefixSet *api.PrefixSet) (bool, config.PrefixSe var prefixSet config.PrefixSet isReqPrefixSet := true if reqPrefixSet.PrefixList != nil { - - prefItem := reqPrefixSet.PrefixList[0] - prefStr := prefItem.Address + "/" + strconv.Itoa(int(prefItem.MaskLength)) - _, ipprefix, _ := net.ParseCIDR(prefStr) - prefix = config.Prefix{ - IpPrefix: *ipprefix, + IpPrefix: reqPrefixSet.PrefixList[0].IpPrefix, MasklengthRange: reqPrefixSet.PrefixList[0].MaskLengthRange, } prefixList := []config.Prefix{prefix} diff --git a/policy/policy_test.go b/policy/policy_test.go index e184f42d..a6d4a4e4 100644 --- a/policy/policy_test.go +++ b/policy/policy_test.go @@ -48,13 +48,13 @@ func TestPrefixCalcurateNoRange(t *testing.T) { updateMsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri) path := table.ProcessMessage(updateMsg, peer)[0] // test - pl1, _ := NewPrefix(net.ParseIP("10.10.0.0"), 24, "") + pl1, _ := NewPrefix("10.10.0.0/24", "") match1 := ipPrefixCalculate(path, pl1) assert.Equal(t, false, match1) - pl2, _ := NewPrefix(net.ParseIP("10.10.0.101"), 24, "") + pl2, _ := NewPrefix("10.10.0.101/24", "") match2 := ipPrefixCalculate(path, pl2) assert.Equal(t, true, match2) - pl3, _ := NewPrefix(net.ParseIP("10.10.0.0"), 16, "21..24") + pl3, _ := NewPrefix("10.10.0.0/16", "21..24") match3 := ipPrefixCalculate(path, pl3) assert.Equal(t, true, match3) } @@ -73,10 +73,10 @@ func TestPrefixCalcurateAddress(t *testing.T) { updateMsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri) path := table.ProcessMessage(updateMsg, peer)[0] // test - pl1, _ := NewPrefix(net.ParseIP("10.11.0.0"), 16, "21..24") + pl1, _ := NewPrefix("10.11.0.0/16", "21..24") match1 := ipPrefixCalculate(path, pl1) assert.Equal(t, false, match1) - pl2, _ := NewPrefix(net.ParseIP("10.10.0.0"), 16, "21..24") + pl2, _ := NewPrefix("10.10.0.0/16", "21..24") match2 := ipPrefixCalculate(path, pl2) assert.Equal(t, true, match2) } @@ -95,10 +95,10 @@ func TestPrefixCalcurateLength(t *testing.T) { updateMsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri) path := table.ProcessMessage(updateMsg, peer)[0] // test - pl1, _ := NewPrefix(net.ParseIP("10.10.64.0"), 24, "21..24") + pl1, _ := NewPrefix("10.10.64.0/24", "21..24") match1 := ipPrefixCalculate(path, pl1) assert.Equal(t, false, match1) - pl2, _ := NewPrefix(net.ParseIP("10.10.64.0"), 16, "21..24") + pl2, _ := NewPrefix("10.10.64.0/16", "21..24") match2 := ipPrefixCalculate(path, pl2) assert.Equal(t, true, match2) } @@ -117,13 +117,13 @@ func TestPrefixCalcurateLengthRange(t *testing.T) { updateMsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri) path := table.ProcessMessage(updateMsg, peer)[0] // test - pl1, _ := NewPrefix(net.ParseIP("10.10.0.0"), 16, "21..23") + pl1, _ := NewPrefix("10.10.0.0/16", "21..23") match1 := ipPrefixCalculate(path, pl1) assert.Equal(t, false, match1) - pl2, _ := NewPrefix(net.ParseIP("10.10.0.0"), 16, "25..26") + pl2, _ := NewPrefix("10.10.0.0/16", "25..26") match2 := ipPrefixCalculate(path, pl2) assert.Equal(t, false, match2) - pl3, _ := NewPrefix(net.ParseIP("10.10.0.0"), 16, "21..24") + pl3, _ := NewPrefix("10.10.0.0/16", "21..24") match3 := ipPrefixCalculate(path, pl3) assert.Equal(t, true, match3) } @@ -144,13 +144,13 @@ func TestPrefixCalcurateNoRangeIPv6(t *testing.T) { updateMsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri) path := table.ProcessMessage(updateMsg, peer)[0] // test - pl1, _ := NewPrefix(net.ParseIP("2001:123:123::"), 48, "") + pl1, _ := NewPrefix("2001:123:123::/48", "") match1 := ipPrefixCalculate(path, pl1) assert.Equal(t, false, match1) - pl2, _ := NewPrefix(net.ParseIP("2001:123:123:1::"), 64, "") + pl2, _ := NewPrefix("2001:123:123:1::/64", "") match2 := ipPrefixCalculate(path, pl2) assert.Equal(t, true, match2) - pl3, _ := NewPrefix(net.ParseIP("2001:123:123::"), 48, "64..80") + pl3, _ := NewPrefix("2001:123:123::/48", "64..80") match3 := ipPrefixCalculate(path, pl3) assert.Equal(t, true, match3) } @@ -170,10 +170,10 @@ func TestPrefixCalcurateAddressIPv6(t *testing.T) { updateMsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri) path := table.ProcessMessage(updateMsg, peer)[0] // test - pl1, _ := NewPrefix(net.ParseIP("2001:123:128::"), 48, "64..80") + pl1, _ := NewPrefix("2001:123:128::/48", "64..80") match1 := ipPrefixCalculate(path, pl1) assert.Equal(t, false, match1) - pl2, _ := NewPrefix(net.ParseIP("2001:123:123::"), 48, "64..80") + pl2, _ := NewPrefix("2001:123:123::/48", "64..80") match2 := ipPrefixCalculate(path, pl2) assert.Equal(t, true, match2) } @@ -193,10 +193,10 @@ func TestPrefixCalcurateLengthIPv6(t *testing.T) { updateMsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri) path := table.ProcessMessage(updateMsg, peer)[0] // test - pl1, _ := NewPrefix(net.ParseIP("2001:123:123:64::"), 64, "64..80") + pl1, _ := NewPrefix("2001:123:123:64::/64", "64..80") match1 := ipPrefixCalculate(path, pl1) assert.Equal(t, false, match1) - pl2, _ := NewPrefix(net.ParseIP("2001:123:123:64::"), 48, "64..80") + pl2, _ := NewPrefix("2001:123:123:64::/48", "64..80") match2 := ipPrefixCalculate(path, pl2) assert.Equal(t, true, match2) } @@ -216,13 +216,13 @@ func TestPrefixCalcurateLengthRangeIPv6(t *testing.T) { updateMsg := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri) path := table.ProcessMessage(updateMsg, peer)[0] // test - pl1, _ := NewPrefix(net.ParseIP("2001:123:123::"), 48, "62..63") + pl1, _ := NewPrefix("2001:123:123::/48", "62..63") match1 := ipPrefixCalculate(path, pl1) assert.Equal(t, false, match1) - pl2, _ := NewPrefix(net.ParseIP("2001:123:123::"), 48, "65..66") + pl2, _ := NewPrefix("2001:123:123::/48", "65..66") match2 := ipPrefixCalculate(path, pl2) assert.Equal(t, false, match2) - pl3, _ := NewPrefix(net.ParseIP("2001:123:123::"), 48, "63..65") + pl3, _ := NewPrefix("2001:123:123::/48", "63..65") match3 := ipPrefixCalculate(path, pl3) assert.Equal(t, true, match3) } @@ -1917,12 +1917,11 @@ func createRoutingPolicy(ds config.DefinedSets, pd ...config.PolicyDefinition) c } func createPrefixSet(name string, prefix string, maskLength string) config.PrefixSet { - _, ippref, _ := net.ParseCIDR(prefix) ps := config.PrefixSet{ PrefixSetName: name, PrefixList: []config.Prefix{ config.Prefix{ - IpPrefix: *ippref, + IpPrefix: prefix, MasklengthRange: maskLength, }}, } diff --git a/test/scenario_test/policy/policy_generator.go b/test/scenario_test/policy/policy_generator.go index 6576c76c..af252031 100644 --- a/test/scenario_test/policy/policy_generator.go +++ b/test/scenario_test/policy/policy_generator.go @@ -73,16 +73,11 @@ func bindPolicy(outputDir, peer, target, policyName string, isReplace bool, defa func createPolicyConfig() *config.RoutingPolicy { - cidr := func(pref string) net.IPNet { - _, n, _ := net.ParseCIDR(pref) - return *n - } - ps0 := config.PrefixSet{ PrefixSetName: "ps0", PrefixList: []config.Prefix{ config.Prefix{ - IpPrefix: cidr("192.168.0.0/16"), + IpPrefix: "192.168.0.0/16", MasklengthRange: "16..24", }}, } @@ -91,9 +86,9 @@ func createPolicyConfig() *config.RoutingPolicy { PrefixSetName: "ps1", PrefixList: []config.Prefix{ config.Prefix{ - IpPrefix: cidr("192.168.20.0/24"), + IpPrefix: "192.168.20.0/24", }, config.Prefix{ - IpPrefix: cidr("192.168.200.0/24"), + IpPrefix: "192.168.200.0/24", }}, } @@ -101,7 +96,7 @@ func createPolicyConfig() *config.RoutingPolicy { PrefixSetName: "ps2", PrefixList: []config.Prefix{ config.Prefix{ - IpPrefix: cidr("192.168.20.0/24"), + IpPrefix: "192.168.20.0/24", }}, } @@ -109,7 +104,7 @@ func createPolicyConfig() *config.RoutingPolicy { PrefixSetName: "ps3", PrefixList: []config.Prefix{ config.Prefix{ - IpPrefix: cidr("2001:0:10:2::/64"), + IpPrefix: "2001:0:10:2::/64", MasklengthRange: "64..128", }}, } @@ -118,9 +113,9 @@ func createPolicyConfig() *config.RoutingPolicy { PrefixSetName: "ps4", PrefixList: []config.Prefix{ config.Prefix{ - IpPrefix: cidr("2001:0:10:20::/64"), + IpPrefix: "2001:0:10:20::/64", }, config.Prefix{ - IpPrefix: cidr("2001:0:10:200::/64"), + IpPrefix: "2001:0:10:200::/64", }}, } @@ -128,7 +123,7 @@ func createPolicyConfig() *config.RoutingPolicy { PrefixSetName: "ps5", PrefixList: []config.Prefix{ config.Prefix{ - IpPrefix: cidr("2001:0:10:20::/64"), + IpPrefix: "2001:0:10:20::/64", }}, } @@ -136,7 +131,7 @@ func createPolicyConfig() *config.RoutingPolicy { PrefixSetName: "ps6", PrefixList: []config.Prefix{ config.Prefix{ - IpPrefix: cidr("192.168.10.0/24"), + IpPrefix: "192.168.10.0/24", }}, } @@ -168,7 +163,7 @@ func createPolicyConfig() *config.RoutingPolicy { PrefixSetName: "psExabgp", PrefixList: []config.Prefix{ config.Prefix{ - IpPrefix: cidr("192.168.100.0/24"), + IpPrefix: "192.168.100.0/24", MasklengthRange: "16..24", }}, } diff --git a/tools/config/example_toml.go b/tools/config/example_toml.go index 51ab4ae6..4988f648 100644 --- a/tools/config/example_toml.go +++ b/tools/config/example_toml.go @@ -75,12 +75,11 @@ func main() { func policy() config.RoutingPolicy { - _, prefix1, _ := net.ParseCIDR("10.3.192.0/21") ps := config.PrefixSet{ PrefixSetName: "ps1", PrefixList: []config.Prefix{ config.Prefix{ - IpPrefix: *prefix1, + IpPrefix: "10.3.192.0/21", MasklengthRange: "21..24", }}, } diff --git a/tools/pyang_plugins/bgpyang2golang.py b/tools/pyang_plugins/bgpyang2golang.py index 9fe8a8ee..569cc9bf 100644 --- a/tools/pyang_plugins/bgpyang2golang.py +++ b/tools/pyang_plugins/bgpyang2golang.py @@ -501,7 +501,7 @@ _type_translation_map = { 'boolean': 'bool', 'empty': 'bool', 'inet:ip-address': 'net.IP', - 'inet:ip-prefix': 'net.IPNet', + 'inet:ip-prefix': 'string', 'inet:ipv4-address': 'net.IP', 'inet:as-number': 'uint32', 'bgp-set-community-option-type' : 'string', |