diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2018-02-26 16:55:04 +0900 |
---|---|---|
committer | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2018-04-03 09:16:41 +0900 |
commit | a25522edddf05653bef26c5ff220f34f7354791f (patch) | |
tree | f45281d921e09ded119d3d48ff2774064e11ab4c /packet/bgp/bgp.go | |
parent | 9697e9d29884608f5dd67af59f456b34317970c0 (diff) |
packet/bgp: Return nil for invalid redirect IP address
When initializing IPv4AddressSpecificExtended or
IPv6AddressSpecificExtended structure, nil value will be returned when
an invalid IP address is given.
But the redirect action extended community types;
- RedirectIPv4AddressSpecificExtended
- RedirectIPv6AddressSpecificExtended
which embed IP address specific extended community types, are not aware
of nil value when initializing, so these redirect action extended
community can be unexpectedly initialized with nil value.
This patch fixes to check return value of the embedded structure and
also return nil when failure of initializing it.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'packet/bgp/bgp.go')
-rw-r--r-- | packet/bgp/bgp.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/packet/bgp/bgp.go b/packet/bgp/bgp.go index 17b53f29..2fea8b44 100644 --- a/packet/bgp/bgp.go +++ b/packet/bgp/bgp.go @@ -7280,7 +7280,11 @@ func (e *RedirectIPv4AddressSpecificExtended) GetTypes() (ExtendedCommunityAttrT } func NewRedirectIPv4AddressSpecificExtended(ipv4 string, localAdmin uint16) *RedirectIPv4AddressSpecificExtended { - return &RedirectIPv4AddressSpecificExtended{*NewIPv4AddressSpecificExtended(EC_SUBTYPE_ROUTE_TARGET, ipv4, localAdmin, false)} + e := NewIPv4AddressSpecificExtended(EC_SUBTYPE_ROUTE_TARGET, ipv4, localAdmin, false) + if e == nil { + return nil + } + return &RedirectIPv4AddressSpecificExtended{*e} } type RedirectIPv6AddressSpecificExtended struct { @@ -7312,7 +7316,11 @@ func (e *RedirectIPv6AddressSpecificExtended) GetTypes() (ExtendedCommunityAttrT } func NewRedirectIPv6AddressSpecificExtended(ipv6 string, localAdmin uint16) *RedirectIPv6AddressSpecificExtended { - return &RedirectIPv6AddressSpecificExtended{*NewIPv6AddressSpecificExtended(EC_SUBTYPE_ROUTE_TARGET, ipv6, localAdmin, false)} + e := NewIPv6AddressSpecificExtended(EC_SUBTYPE_ROUTE_TARGET, ipv6, localAdmin, false) + if e == nil { + return nil + } + return &RedirectIPv6AddressSpecificExtended{*e} } type RedirectFourOctetAsSpecificExtended struct { |