summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp/bgp.go
AgeCommit message (Collapse)Author
2018-07-07follow Standard Go Project LayoutFUJITA Tomonori
https://github.com/golang-standards/project-layout Now you can see clearly what are private and public library code. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-07-06api: remove table/ usage in util.goFUJITA Tomonori
This is a part of work removing table/ usage in api/. api/ will depend on only protobuf stuff and packet/. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-06-22fixing some typos and found one conversion bugJeff Bean
2018-06-22Fixing all megacheck errors.Jeff Bean
2018-06-21packet/bgp: Fix length calc when multiple RTM NLRIsIWASE Yusuke
When multiple RTM NLRIs are composed in a single MP_REACH_NLRI, the current implementation will fail to decode those NLRIs because RouteTargetMembershipNLRI.DecodeFromBytes() tests the length of the given bytes even if including the subsequent bytes. This patch fixes to cut the bytes by using the prefix length before testing the byte length. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-06-21packet/bgp: Missing New func for BGP CapabilitiesIWASE Yusuke
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-06-14Pull regex into variables to prevent the regex to compile in the hotpathJeff Bean
2018-06-13gobgpd: Use gRPC APIs Instead of BgpServer functionsSatoshi Fujimoto
In order to integarate the setting via configuration files and via gRPC API, This commit fixes gobgpd to use gRPC APIs instead of using BgpServer functions directly, for consistency. Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
2018-06-11packet/bgp: use 71 for BGP LLGR capability codeVincent Bernat
Since the RFC is only a draft, IANA didn't attribute a code yet. However, Juniper is supporting this feature since a long time and is using 71. I don't know if Cisco is using the same value. BIRD will ship soon with this capability too and will use 71 too. Wireshark also understands capability code 71 as LLGR. Tested with Juniper vRR 16.1 and this configuration: ```yaml peer-groups: - config: peer-group-name: others peer-as: 65000 ttl-security: config: enabled: true ttl-min: 255 graceful-restart: config: enabled: true long-lived-enabled: true notification-enabled: true restart-time: 1 afi-safis: - config: afi-safi-name: ipv6-unicast mp-graceful-restart: config: enabled: true long-lived-graceful-restart: config: enabled: true restart-time: 120 ``` Enabling regular graceful restart for the appropriate AFI/SAFI is needed to make LLGR work on the Juniper side. Unfortunately, GoBGP doesn't allow to set restart-time to 0 (this is the same as using the default value of 90s), therefore we have a small delay before LLGR kicks in (during which routes are preserved). A way to set restart time to 0 would be welcome.
2018-05-11packet/bgp: remove bogus debug printFUJITA Tomonori
fix a mess in the commit 388ef503f2c9cae. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-05-11packet/bgp: fix OpenMessage Parse crash with bogus dataFUJITA Tomonori
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-05-07table: use shorter key for map of ipv4 and ipv6 prefixesFUJITA Tomonori
save about 100MB memory. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-04-03packet/bgp: Getter functions for AS segmentIWASE Yusuke
This patch adds getter functions for the segment type and AS list of each segment without using type assertion. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-04-03packet/bgp: Return nil for invalid redirect IP addressIWASE Yusuke
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>
2018-04-03packet/bgp: Initializer func for PMSI Tunnel ID typesIWASE Yusuke
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-04-03packet/bgp: Avoid data races when serializingIWASE Yusuke
Because "Serialize()" functions of NLRIs or PathAttributes can be called from some different goroutines, updating fields of a structure can cause data races. This patch moves the normalization for each field (mostly length and flags calculation) into "NewXxx()" or "DecodeFromBytes()" and avoids the data races. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-04-03packet/bgp: Initializer func for EVPN NLRIsIWASE Yusuke
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-04-03packet/bgp: Remove length argument from NewEVPNNLRIIWASE Yusuke
The length value can be retrieved from the route type specific data field and need not to be specified at the initialization. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-04-03packet/bgp: Missing funcs to calc byte length of NLRIIWASE Yusuke
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-04-03packet/bgp: Remove binary field of RouteDistinguisherIWASE Yusuke
Keeping binary representation increases the size of structure and can cause data races. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-03-19packet/bgp: make serialization of ipv4/v6 nlri goroutine-safeFUJITA Tomonori
The serialization of ipv4/v6 nlri should be goroutine-safe but somehow not. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-02-22packet/bgp: Return specified type value for UnknownExtendedIWASE Yusuke
Currently, "UnknownExtended.GetTypes()" returns always the constant values even if "Type" value is given. This patch fixes to return the given type value and use the first "Value" byte as the sub type. Also, introduces "NewUnknownExtended()" function for the convenience. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-02-22packet/bgp: Flatten structure of OpaqueExtendedIWASE Yusuke
Currently, to instantiate sub types of the Opaque Extended Community, it is required to instantiate "OpaqueExtended" and its value type (e.g., "ValidationExtended" or "EncapExtended") and also specify its sub type. This can cause the confusion of the outer and inner (value) structures and the unmatch of the value structure and its sub type. This patch makes the "OpaqueExtended" into more flat structure and introduces "NewXxxExtended()" function to improve usability. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-02-22packet/bgp: Fix a typo of TunnelType stringIWASE Yusuke
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-02-21packet/bgp: Rename AigpTLV to AigpTLVInterfaceIWASE Yusuke
The other interface types in "packet/bgp" package have "Interface" suffix. This patch fixes to follow this naming convention. Golang's naming convention recommends to use "er" suffix though. Also, this patch moves the AIGP TLVs definitions to the near of the PathAttributeAigp structure and defines NewAigpTLVDefault function. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-02-19packet/bgp: Fix a typo of TunnelEncapSubTLVUnknownIWASE Yusuke
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-02-16cli: Support to advertise PMSI Tunnel AttributeIWASE Yusuke
This patch enables "gobgp" command to advertise the PMSI Tunnel Attribute which is appended to the EVPN Inclusive Multicast Ethernet Tag routes for example. Usage Example: $ gobgp global rib -a evpn add multicast 10.0.0.1 etag 10 rd 65000:100 pmsi ingress-repl 100 1.1.1.1 $ gobgp global rib -a evpn Network Labels Next Hop AS_PATH Age Attrs *> [type:multicast][rd:65000:100][etag:10][ip:10.0.0.1] 0.0.0.0 00:00:00 [{Origin: ?} {Pmsi: type: ingress-repl, label: 100, tunnel-id: 1.1.1.1}] Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-02-16packet/bgp: Fix bitSize of ESI typeIWASE Yusuke
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-02-13packet/bgp: Refactor TunnelEncapSubTLV structureIWASE Yusuke
This patch refactors the structure of TunnelEncapSubTLV sub-types to have the similar structure of PathAttribute sub-types, and makes easy to implement MarshalJSON() functions for TunnelEncapSubTLV sub-types. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-02-13packet/bgp: Missing String()/MarshalJSON() of PathAttribute subsIWASE Yusuke
First this patch removes String() and MarshalJSON() functions of PathAttribute struct. This helps to find the struct types which embed PathAttribute struct without having own String() and MarshalJSON() functions. If those functions of PathAttribute struct are unexpectedly called, those functions are not enough to display its contents. Then this patch implements missing String() and MarshalJSON() functions for some struct types which embed PathAttribute struct. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-02-13packet/bgp: Remove raw binary field on PathAttributeIWASE Yusuke
The current implementation, PathAttribute stores the raw binary data as "Value" field, but this field increases the memory consumption. This patch removes "Value" field to slim down. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-01-12packet/bgp: use strconv.ParseUint instead of strconv.Atoi()Vincent Bernat
Atoi() returns a signed int. On a 32-bit platform, this is not big enough to fit an unsigned 32-bit int. Replace all occurrences of Atoi() to ParseUint() with the appropriate size as a parameter. This fix this failure: ``` --- FAIL: Test_ParseEthernetSegmentIdentifier (0.00s) Error Trace: bgp_test.go:1181 Error: Expected nil, but got: &errors.errorString{s:"invalid esi values for type ESI_AS: [2864434397 287454020]"} Error Trace: bgp_test.go:1182 Error: Not equal: bgp.EthernetSegmentIdentifier{Type:0x5, Value:[]uint8{0xaa, 0xbb, 0xcc, 0xdd, 0x11, 0x22, 0x33, 0x44, 0x0}} (expected) != bgp.EthernetSegmentIdentifier{Type:0x5, Value:[]uint8{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}} (actual) Diff: --- Expected +++ Actual @@ -1,2 +1,2 @@ -(bgp.EthernetSegmentIdentifier) ESI_AS | as 2864434397, local discriminator 287454020 +(bgp.EthernetSegmentIdentifier) ESI_AS | as 0, local discriminator 0 FAIL FAIL github.com/osrg/gobgp/packet/bgp 0.003s ```
2017-12-30cli: Slash separated offset arg for FlowSpec PrefixIWASE Yusuke
Currently, "gobgp" command supports only; "<ipv6 prefix>/<len> <offset>" # space separated format to specify the prefix offset for the FlowSpec destination/source rules, but the displayed format with "rib" command is; "<ipv6 prefix>/<len>/<offset>" # slash separated and the slash separated format is not allowed as command arguments. This patch enables to specify the slash separated format for the FlowSpec destination/source rules arguments and resolve unmatch of the input/output formats. Example: $ gobgp global rib -a ipv6-flowspec add match destination 0:db8:1::1/64/16 then accept $ gobgp global rib -a ipv6-flowspec Network Next Hop AS_PATH Age Attrs *> [destination: 0:db8:1::/64/16] fictitious 00:00:00 [{Origin: ?} Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-12-30cli: Support EVPN Default Gateway Extended CommunityIWASE Yusuke
This patch enables to support the Default Gateway Extended Community on the EVPN MAC/IP Advertisement route. Usage Example: $ gobgp global rib -a evpn add macadv aa:bb:cc:dd:ee:ff 10.0.0.1 etag 10 label 20,30 rd 1.1.1.1:65000 default-gateway $ gobgp global rib -a evpn Network Labels Next Hop AS_PATH Age Attrs *> [type:macadv][rd:1.1.1.1:65000][etag:10][mac:aa:bb:cc:dd:ee:ff][ip:10.0.0.1] [20,30] 0.0.0.0 00:00:00 [{Origin: ?} {Extcomms: [default-gateway]} [ESI: single-homed]] Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-12-06packet/bgp: JSON encode of MP_UNREACH_NLRI attributeVincent Bernat
MP_REACH_NLRI was already correctly encoded in JSON, while this was not the case for MP_UNREACH_NLRI. Before: ```json "PathAttributes": [ { "type": 15, "value": "AAIBQCABDbgAEwAA" } ] ``` After: ```json "PathAttributes": [ { "type": 15, "afi": 2, "value": [ { "prefix": "2001:db8:8::/64" } ], "safi": 1 } ] ``` This commit also adds two tests not directly related to JSON encoding as I was first thinking the problem may be related to incorrect parsing of the path attribute.
2017-11-28packet/bgp: Use fixed len types in FlowSpec componentsIWASE Yusuke
Currently, the "FlowSpecComponentItem" uses int type for the "Op" and "Value" fields, but Golang int type has 4 bytes length on the 32-bit env and 8 bytes length on the 64-bit env. For example, to support the SNAP (Type 20) rule, which has 5 bytes value field, int type has not enough length on 32-bit env. This patch fixes to use the fixed length integer types for the FlowSpec components and avoid overflows of value range. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-11-24packet/bgp: Use regexp to parse FlowSpec rulesIWASE Yusuke
Currently, the parser for the string representation of FlowSpec rules splits the given string into characters and validates them character by character. So we need to handle the unexpected white spaces carefully. This patch introduces the regular expressions to parse the FlowSpec rules and simplify the parsers. Also improves robustness for the unexpectedly inserted white spaces like "& == tcp". Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-11-24packet/bgp: Refactor construction of FlowSpec rules stringIWASE Yusuke
This patch introduces String() functions for the flags and reserved values related to the FlowSpec rules. Also removes the unused types and functions. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-11-24packet/bgp: Invert FlowSpec bitmask operand positionIWASE Yusuke
Currently, if the both NOT and MATCH bit are set for the FlowSpec bitmask operand, the string representation will be "=!". For the readability and the consistency with the representation of numeric operator, it should be "!=". This patch inverts "=!" into "!=" for the bitmask operand. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-11-24cli: Improve arguments extraction for FlowSpec rulesIWASE Yusuke
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-11-24packet/bgp: Sort FlowSpec rules when decoding/creatingIWASE Yusuke
Currently, we sort the FlowSpec rules when creating a new path containing the FlowSpec NLRI and when parsing CLI arguments for the FlowSpec rules. This patch moves sorting the rules into the inside of the "packet" module and sorts them when decoding binary and creating new NLRI. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-11-23table: fix merging of v4 paths with addpath enabledFUJITA Tomonori
V4 NLRI needs more 4 bytes with addpath enabled. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-11-21packet/bgp: Support EVPN Router's MAC Extended CommunityIWASE Yusuke
This patch supports EVPN Router's MAC Extended Community which described on "draft-ietf-bess-evpn-inter-subnet-forwarding". According to "draft-ietf-bess-evpn-prefix-advertisement" This extended community might be carried with EVPN IP Prefix Route NLRI. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-11-21packet/bgp: Zeros if GW in EVPN Prefix route omittedIWASE Yusuke
According to "draft-ietf-bess-evpn-prefix-advertisement-08", the GW IP field SHOULD be zero if it is not used, but currently, GoBGP skips encoding the GW IP field (not composed). This patch fixes to fill zeros to solve this problem. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-11-21packet/bgp: Check range of EVPN related Label fieldIWASE Yusuke
This patch enables to check the value range of Label included in EVPN routes or PMSI Tunnel attribute when decoding and serialising it. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-11-21packet/bgp: Use ESI str in EVPN Ethernet Segment RouteIWASE Yusuke
This patch fixes to use the string representation of ESI in the string representation of EVPN Ethernet Segment Route. Currently, displayed in the default representation of ESI structure. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-11-21packet/bgp: Avoid raw binary in EVPN ESI stringIWASE Yusuke
Currently, the value field of EVPN ESI might be corrupted when ESI type is ARBITRARY (not "single-homed") or unknown type because the value field will be formatted as the raw byte slice in this case. This patch fixes to convert the byte slice into the colon separated hex values which is corresponding to the format of the CLI input. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-11-21packet/bgp: Use decimal AS number in EVPN ESIIWASE Yusuke
Currently, the representation of AS number in EVPN ESI Type AS (Type 5) uses the colon separated 2 octet values format, but in other places, the AS4_PATH attribute for example, the single decimal format is used. This patch fixes to use the decimal AS number for the consistency with the AS_PATH/AS4_PATH attributes and also the CLI input format. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-11-21packet/bgp: EVPN ESI parser from string sliceIWASE Yusuke
This patch introduces a new function to parse EVPN ESI from string slice which passed via CLI for example. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-11-20packet/bgp: Rename snake case to camel caseIWASE Yusuke
This patch renames some variable names in snake case (e.g., "last_byte_value") to that in the camel case (e.g., "lastByte") because Go prefers the camel case for variable names. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>