Skip to content

Add ERSPAN Type II header support#484

Open
tcheever wants to merge 1 commit intogoogle:masterfrom
tcheever:erspan2
Open

Add ERSPAN Type II header support#484
tcheever wants to merge 1 commit intogoogle:masterfrom
tcheever:erspan2

Conversation

@tcheever
Copy link

Also includes an ERSPAN connection type with basic functions.

@googlebot
Copy link
Collaborator

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@tcheever
Copy link
Author

I signed it!

@lhausermann
Copy link
Contributor

Dear @tcheever would you double check if you signed the CLA with the right email address ? It should be the one linked to you GitHub account (see the CLA robot message)

@tcheever
Copy link
Author

@lhausermann Hmm, I do have the correct email address and github username in the CLA. I did not have a publicly visible email address in my github settings, however, so I've exposed that now.

@googlebot
Copy link
Collaborator

CLAs look good, thanks!

Copy link
Contributor

@lhausermann lhausermann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After CLA is signed, I made some review of your code. Would you mind make some cleanups ?
Thanks for your contribution


// Header contains all of the fields found in an ERSPAN2 header
// https://tools.ietf.org/html/draft-foschiano-erspan-03
type Header struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be called ERPSANIIHeader

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, good point. I had the different layers separated into their own packages so callers would have erspan2.Header or erspan2.NewHeader(). There are a few things, as you've pointed out, than need to be cleaned up a bit to fit into the layers package.

return nil
}

// Conn - A connection to a device to send packets within ERSPAN2 encapsulation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this "Conn" struct + methods should be in a Layer. I guess you are using that in your app code to send packets, but a layer should stick to DecodeFromBytes and SerializeTo methods

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, had a feeling that would be the feedback but worth a shot! I'll remove the connection portions.

}

// Dial - Connect to a device given an IP address string.
func Dial(addr string, opts *ConnOpts) (*Conn, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as Conn() here

return e.opts
}

const (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If needed, please use the const already defined in Gopacket other layers (ie IP / Ethernet)


// Need root permissions or net_raw_sock linux capabilities for Dial()
// This test is skipped but here for documentation
func TestDialWriteClose(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for Conn()

@tcheever
Copy link
Author

Fixing the golint complaints

@tcheever
Copy link
Author

Ok, I fixed golint on my system. For some reason the binary wasn't executable anymore even though it had adequate permissions and was of the right format. Updating golint fixed the issue.

@gconnell
Copy link
Contributor

Laurent, quick ping on this: are you okay with the changes made?

Also, it looks like this isn't currently linked into LayerType stuff. Could you add a Layer type to layers/layertypes.go?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants