summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--api/gobgp.pb.go25
-rw-r--r--api/gobgp.proto3
-rw-r--r--gobgp/cmd/policy.go24
-rw-r--r--table/policy.go5
4 files changed, 28 insertions, 29 deletions
diff --git a/api/gobgp.pb.go b/api/gobgp.pb.go
index 819be3ad..d4ec9c0a 100644
--- a/api/gobgp.pb.go
+++ b/api/gobgp.pb.go
@@ -26,8 +26,8 @@ It has these top-level messages:
MatchSet
Conditions
CommunityAction
- AsPrependAction
MedAction
+ AsPrependAction
Actions
Statement
PolicyDefinition
@@ -387,8 +387,9 @@ func (m *Peer) GetInfo() *PeerInfo {
}
type Prefix struct {
- 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"`
+ IpPrefix string `protobuf:"bytes,1,opt,name=ip_prefix" json:"ip_prefix,omitempty"`
+ MaskLengthMin uint32 `protobuf:"varint,2,opt,name=mask_length_min" json:"mask_length_min,omitempty"`
+ MaskLengthMax uint32 `protobuf:"varint,3,opt,name=mask_length_max" json:"mask_length_max,omitempty"`
}
func (m *Prefix) Reset() { *m = Prefix{} }
@@ -496,6 +497,15 @@ func (m *CommunityAction) Reset() { *m = CommunityAction{} }
func (m *CommunityAction) String() string { return proto.CompactTextString(m) }
func (*CommunityAction) ProtoMessage() {}
+type MedAction struct {
+ Type int32 `protobuf:"varint,1,opt,name=type" json:"type,omitempty"`
+ Value int64 `protobuf:"varint,2,opt,name=value" json:"value,omitempty"`
+}
+
+func (m *MedAction) Reset() { *m = MedAction{} }
+func (m *MedAction) String() string { return proto.CompactTextString(m) }
+func (*MedAction) ProtoMessage() {}
+
type AsPrependAction struct {
Asn uint32 `protobuf:"varint,1,opt,name=asn" json:"asn,omitempty"`
Repeat uint32 `protobuf:"varint,2,opt,name=repeat" json:"repeat,omitempty"`
@@ -506,15 +516,6 @@ func (m *AsPrependAction) Reset() { *m = AsPrependAction{} }
func (m *AsPrependAction) String() string { return proto.CompactTextString(m) }
func (*AsPrependAction) ProtoMessage() {}
-type MedAction struct {
- Type int32 `protobuf:"varint,1,opt,name=type" json:"type,omitempty"`
- Value int64 `protobuf:"varint,2,opt,name=value" json:"value,omitempty"`
-}
-
-func (m *MedAction) Reset() { *m = MedAction{} }
-func (m *MedAction) String() string { return proto.CompactTextString(m) }
-func (*MedAction) ProtoMessage() {}
-
type Actions struct {
RouteAction RouteAction `protobuf:"varint,1,opt,name=route_action,enum=gobgpapi.RouteAction" json:"route_action,omitempty"`
Community *CommunityAction `protobuf:"bytes,2,opt,name=community" json:"community,omitempty"`
diff --git a/api/gobgp.proto b/api/gobgp.proto
index c3f36061..b91ef183 100644
--- a/api/gobgp.proto
+++ b/api/gobgp.proto
@@ -173,7 +173,8 @@ message Peer {
message Prefix {
string ip_prefix = 1;
- string mask_length_range = 2;
+ uint32 mask_length_min = 2;
+ uint32 mask_length_max = 3;
}
message PrefixSet {
diff --git a/gobgp/cmd/policy.go b/gobgp/cmd/policy.go
index 4f9d1f0f..ab2e08b3 100644
--- a/gobgp/cmd/policy.go
+++ b/gobgp/cmd/policy.go
@@ -37,7 +37,6 @@ func formatPolicyPrefix(head bool, indent int, psl []*api.PrefixSet) string {
sIndent := strings.Repeat(" ", indent)
maxNameLen := 0
maxPrefixLen := 0
- maxRangeLen := 0
for _, ps := range psl {
if len(ps.Name) > maxNameLen {
maxNameLen = len(ps.Name)
@@ -46,9 +45,6 @@ func formatPolicyPrefix(head bool, indent int, psl []*api.PrefixSet) string {
if len(p.IpPrefix) > maxPrefixLen {
maxPrefixLen = len(p.IpPrefix)
}
- if len(p.MaskLengthRange) > maxRangeLen {
- maxRangeLen = len(p.MaskLengthRange)
- }
}
}
@@ -59,23 +55,22 @@ func formatPolicyPrefix(head bool, indent int, psl []*api.PrefixSet) string {
if len("Prefix") > maxPrefixLen {
maxPrefixLen = len("Prefix")
}
- if len("MaskRange") > maxRangeLen {
- maxRangeLen = len("MaskRange")
- }
}
- format := "%-" + fmt.Sprint(maxNameLen) + "s %-" + fmt.Sprint(maxPrefixLen) + "s %-" + fmt.Sprint(maxRangeLen) + "s\n"
+ format := fmt.Sprintf("%%-%ds %%-%ds ", maxNameLen, maxPrefixLen)
if head {
- buff.WriteString(fmt.Sprintf(format, "Name", "Address", "MaskRange"))
+ buff.WriteString(fmt.Sprintf(format, "Name", "Prefix"))
+ buff.WriteString("MaskLengthRange\n")
}
for _, ps := range psl {
for i, p := range ps.List {
- prefix := fmt.Sprintf("%s", p.IpPrefix)
if i == 0 {
- buff.WriteString(fmt.Sprintf(format, ps.Name, prefix, p.MaskLengthRange))
+ buff.WriteString(fmt.Sprintf(format, ps.Name, p.IpPrefix))
+ buff.WriteString(fmt.Sprintf("%d..%d\n", p.MaskLengthMin, p.MaskLengthMax))
} else {
buff.WriteString(fmt.Sprintf(sIndent))
- buff.WriteString(fmt.Sprintf(format, "", prefix, p.MaskLengthRange))
+ buff.WriteString(fmt.Sprintf(format, "", p.IpPrefix))
+ buff.WriteString(fmt.Sprintf("%d..%d\n", p.MaskLengthMin, p.MaskLengthMax))
}
}
}
@@ -138,7 +133,7 @@ func showPolicyPrefix(args []string) error {
}
if globalOpts.Quiet {
for _, p := range ps.List {
- fmt.Printf("%s %s\n", p.IpPrefix, p.MaskLengthRange)
+ fmt.Printf("%s %d..%d\n", p.IpPrefix, p.MaskLengthMin, p.MaskLengthMax)
}
return nil
}
@@ -186,7 +181,8 @@ func parsePrefixSet(eArgs []string) (*api.PrefixSet, error) {
if min >= max {
return nil, fmt.Errorf("invalid mask length range: %s\nlarge value to the right from the left", maskRange)
}
- prefix.MaskLengthRange = maskRange
+ prefix.MaskLengthMin = uint32(min)
+ prefix.MaskLengthMax = uint32(max)
}
prefixList := []*api.Prefix{prefix}
prefixSet := &api.PrefixSet{
diff --git a/table/policy.go b/table/policy.go
index 6d33a35f..696b28e0 100644
--- a/table/policy.go
+++ b/table/policy.go
@@ -171,8 +171,9 @@ func (p *Prefix) Match(path *Path) bool {
func (p *Prefix) ToApiStruct() *api.Prefix {
return &api.Prefix{
- IpPrefix: p.Prefix.String(),
- MaskLengthRange: fmt.Sprintf("%d..%d", p.MasklengthRangeMin, p.MasklengthRangeMax),
+ IpPrefix: p.Prefix.String(),
+ MaskLengthMin: uint32(p.MasklengthRangeMin),
+ MaskLengthMax: uint32(p.MasklengthRangeMax),
}
}