osrg / gobgp

BGP implemented in the Go Programming Language
https://osrg.github.io/gobgp/
Apache License 2.0
3.64k stars 696 forks source link

BGP flowspec TCP flags #1173

Closed Matt-Texier closed 7 years ago

Matt-Texier commented 7 years ago

Hi Guys,

I am in the process of building a piece of SW that is using GoBGP flowspec.

I have to humbly congrats what you did on flowspec and in particular support of RFC 7674 which solves interop issues with certain vendors (I have been working on this one).

Would it be possible to improve support of TCP flags ? Ideally an approach similar to TCPDUMP would be nice ... something like first letter of the flag when the flag is set to 1 (like S for syn, SA for syn ack, like CEUAPRSF when all flags set to 1 !) and, as a fall back, the decimal value of the flag byte of the TCP header.

Please keep in mind that those rules are applied mainly for DDoS mitigation and as such TCP packet are very often crafted via DDoS tools or via binary protocol editor ... even things that doesn't make any sense could be received.

I would be happy to help ... But I am more a network designer and occasionally C coder (wireshark dissectors). Feel free to ask ...

Thanks Matt.

ishidawataru commented 7 years ago

Hi, @Matt-Texier

Do you need kinda syntax sugar for current CLI? Or current CLI can't achieve something you need to do? (even with ugly syntax)

Matt-Texier commented 7 years ago

Hi,

I am working on a setup to test it more extensively and I'll let you know ... It was not obvious from the doc that all TCP flags was supported.

Thanks Matt.

Matt-Texier commented 7 years ago

BTW, coming back on my initial question, I was more willing to use API gRPC calls to setup Flowspec RIB. Is it doable and do you have an example of RIB updates using gRPC API ?

Thanks Matt.

Matt-Texier commented 7 years ago

Hi,

I did a bit of reverse engineering of cmd package. As the CLI relies on gRPC API, I was expecting to understand better how to use the API to add flowspec route. Good thing is that I understand now how parser is working but it is still unclear how the API is used to add path ...

Could you please point me to the right file an piece of code I should look at ?

I get lost in the middle of my reverse engineering when you where using func pointers ... in the cobra function :-) !

If you have a "simple" example of a flowspec gRPC client that is adding a route to a server, It would be really helpful ...

Thanks in advance for your help,

Matt.

ishidawataru commented 7 years ago

cmd package is using client package which wraps gRPC API.

https://github.com/osrg/gobgp/blob/master/client/client.go#L341-L343

This is the function, which CLI is using for adding a path.

Simple example to use that

package main

import (
        "strings"

        "github.com/osrg/gobgp/client"
        "github.com/osrg/gobgp/gobgp/cmd"
        "github.com/osrg/gobgp/packet/bgp"
        "github.com/osrg/gobgp/table"
)

func main() {
        cli, _ := client.NewGoBGPClient("")
        path, _ := cmd.ParsePath(bgp.RF_FS_IPv4_UC, strings.Split("match destination 10.0.0.0/24 then discard", " "))
        cli.AddPath([]*table.Path{path})
}
Matt-Texier commented 7 years ago

Thanks for pointing me to this file. Very helpful and much appreciated, Matt.

ishidawataru commented 7 years ago

Not at all 😄