Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/ipam: IP based macaddr #254

Merged
merged 11 commits into from
Aug 2, 2016
Merged

pkg/ipam: IP based macaddr #254

merged 11 commits into from
Aug 2, 2016

Conversation

steveej
Copy link
Member

@steveej steveej commented Jun 21, 2016

Closes #196.

@dcbw
Copy link
Member

dcbw commented Jun 22, 2016

@steveej I'm a bit nervous about hardcoding this behavior in ConfigureInterface(). A plugin might create its own veth pair and then use ConfigureInterface() to do the actual IPAM setup, but may want to preserve the MAC it already set when the veth was created. Is there a way to make this behavior optional, or only performed if the 'ptp' plugin is used? Maybe it could be a separate function to set the hwaddr that the standard plugins call instead of being in ConfigureInteface().

@steveej
Copy link
Member Author

steveej commented Jun 22, 2016

@dcbw

I'm a bit nervous about hardcoding this behavior in ConfigureInterface()

I see your concern, and I think it's worth re-designing this. Instead of checking the interface type within IPAM, it should be called by the main plugins after IPAM allocated the IP address.

@steveej
Copy link
Member Author

steveej commented Jun 29, 2016

I've restructured the code and started to add tests for the ip package. Not sure if ipam.ConfigureIface should also go into ip.

Reviews welcome at this point! @containernetworking/cni-maintainers

@steveej
Copy link
Member Author

steveej commented Jul 9, 2016

ping @containernetworking/cni-maintainers

/cc @squeed you're invited to review this too!

}
}

mac := prefix
Copy link
Member

Choose a reason for hiding this comment

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

This string conversion is a little awkward. Both of these types are just wrappers around []byte. So, you can do:

ip = ip.To4()
addr := (net.HardwareAddr)(append([]byte{0x0a, 0x58}, ip...))

This removes one of the err types

Copy link
Member Author

Choose a reason for hiding this comment

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

I can't see it working that easily because we want to strip out the . characters.

Copy link
Member

Choose a reason for hiding this comment

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

It really does :-). The byte arrays are the real numerical address value, not the string.

@dcbw
Copy link
Member

dcbw commented Jul 22, 2016

Looks mostly good to me. You could squash some of the commits together since some are just fixups based on review comments. And the coveralls thing...

steveej added 5 commits July 22, 2016 15:17
* _suite.go and _test.go file should be in the same package, using the
  _test package for that, which requires some fields and methods to be
  exported
* Introduce error type for cleaner error handling
* test adaptions for error type checking
This will give deterministic MAC addresses for all interfaces CNI
creates and manages the IP for:
* bridge: container veth and host bridge
* macvlan: container veth
* ptp: container veth and host veth
steveej added 3 commits July 22, 2016 15:34
* bridge: Test the following interface's hardware address for the CNI specific
prefix:
  - bridge with IP address
  - container veth
* plugins/macvlan test: ensure hardware addr
@steveej
Copy link
Member Author

steveej commented Jul 25, 2016

@dcbw I squashed as much as I felt comfortable doing so. (hopefully) last review please ;-)

@dcbw
Copy link
Member

dcbw commented Jul 26, 2016

@steveej see my comment here 924b30b#r71946686 , that still needs to be addressed.

@dcbw
Copy link
Member

dcbw commented Jul 26, 2016

After that, LGTM.

@steveej
Copy link
Member Author

steveej commented Aug 1, 2016

@dcbw

see my comment here 924b30b#r71946686 , that still needs to be addressed.
After that, LGTM.

That case is already covered because the function in question only uses the last 4 bytes. I added a test to demonstrate the correctness.

/cc @squeed

@squeed
Copy link
Member

squeed commented Aug 2, 2016

👍 LGTM

@steveej steveej merged commit f5ead79 into containernetworking:master Aug 2, 2016
@steveej steveej deleted the ip-based-macaddr branch August 2, 2016 00:43
@tomdee tomdee mentioned this pull request Jan 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants