summaryrefslogtreecommitdiffhomepage
path: root/pkg/packet
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/packet')
-rw-r--r--pkg/packet/bgp/bgp.go23
1 files changed, 13 insertions, 10 deletions
diff --git a/pkg/packet/bgp/bgp.go b/pkg/packet/bgp/bgp.go
index 01251167..1be42ec5 100644
--- a/pkg/packet/bgp/bgp.go
+++ b/pkg/packet/bgp/bgp.go
@@ -8443,6 +8443,9 @@ func (p *PathAttributePmsiTunnel) MarshalJSON() ([]byte, error) {
}
func NewPathAttributePmsiTunnel(typ PmsiTunnelType, isLeafInfoRequired bool, label uint32, id PmsiTunnelIDInterface) *PathAttributePmsiTunnel {
+ if id == nil {
+ return nil
+ }
// Flags(1) + TunnelType(1) + Label(3) + TunnelID(variable)
l := 5 + id.Len()
t := BGP_ATTR_TYPE_PMSI_TUNNEL
@@ -8466,22 +8469,22 @@ func ParsePmsiTunnel(args []string) (*PathAttributePmsiTunnel, error) {
return nil, fmt.Errorf("invalid pmsi tunnel arguments: %s", args)
}
- pmsi := NewPathAttributePmsiTunnel(0, false, 0, nil)
-
+ var tunnelType PmsiTunnelType
+ var isLeafInfoRequired bool
switch args[0] {
case "ingress-repl":
- pmsi.TunnelType = PMSI_TUNNEL_TYPE_INGRESS_REPL
+ tunnelType = PMSI_TUNNEL_TYPE_INGRESS_REPL
default:
typ, err := strconv.ParseUint(args[0], 10, 8)
if err != nil {
return nil, fmt.Errorf("invalid pmsi tunnel type: %s", args[0])
}
- pmsi.TunnelType = PmsiTunnelType(typ)
+ tunnelType = PmsiTunnelType(typ)
}
indx := 1
if args[indx] == "leaf-info-required" {
- pmsi.IsLeafInfoRequired = true
+ isLeafInfoRequired = true
indx++
}
@@ -8489,21 +8492,21 @@ func ParsePmsiTunnel(args []string) (*PathAttributePmsiTunnel, error) {
if err != nil {
return nil, fmt.Errorf("invalid pmsi tunnel label: %s", args[indx])
}
- pmsi.Label = uint32(label)
indx++
- switch pmsi.TunnelType {
+ var id PmsiTunnelIDInterface
+ switch tunnelType {
case PMSI_TUNNEL_TYPE_INGRESS_REPL:
ip := net.ParseIP(args[indx])
if ip == nil {
return nil, fmt.Errorf("invalid pmsi tunnel identifier: %s", args[indx])
}
- pmsi.TunnelID = &IngressReplTunnelID{Value: ip}
+ id = &IngressReplTunnelID{Value: ip}
default:
- pmsi.TunnelID = &DefaultPmsiTunnelID{Value: []byte(args[indx])}
+ id = &DefaultPmsiTunnelID{Value: []byte(args[indx])}
}
- return pmsi, nil
+ return NewPathAttributePmsiTunnel(tunnelType, isLeafInfoRequired, uint32(label), id), nil
}
type PathAttributeIP6ExtendedCommunities struct {