-
Notifications
You must be signed in to change notification settings - Fork 883
networking: refactor and split KVM logic #3733
base: master
Are you sure you want to change the base?
Conversation
Travis is failing due to license header missing on the two new files. |
Thank you!
If the intention is to keep the Xen network initialization functions in
stage1-xen, then ensureBridgeIsUp needs to be exported. (Also I am
getting an error in types.go, I had to add "package networking" at the
top.)
Otherwise, we could introduce XenAddNetwork and XenSetup to
networking/vm/kvm.go and it would look pretty much like the following.
How do you prefer to proceed?
+func XenSetup(n *networking.Networking, debug bool) {
+ n.CreateNS = false
+ n.AddNet = XenAddNetwork
+ n.DelNet = XenDelNetwork
+}
+
+func XenAddNetwork(n *networking.Networking, anet *networking.ActiveNet) error {
+ if anet.Conf.Type == "flannel" {
+ return errors.New("cannot transform flannel network into basic network")
+ }
+
+ anet.Runtime.IfName = "vif"
+ switch anet.Conf.Type {
+ case "ptp":
+ err := ExecNetIPAM(n, anet, "vif")
+ if err != nil {
+ return err
+ }
+
+ case "bridge":
+ config := BridgeNetConf{
+ BrName: "rkt0",
+ MTU: 1500,
+ }
+ if err := json.Unmarshal(anet.ConfBytes, &config); err != nil {
+ return errwrap.Wrap(fmt.Errorf("error parsing %q result", anet.Conf.Name), err)
+ }
+
+ _, err := EnsureBridgeIsUp(config.BrName, config.MTU)
+ if err != nil {
+ return errwrap.Wrap(errors.New("error in time of bridge setup"), err)
+ }
+
+ anet.Runtime.IfName = config.BrName
+ err2 := ExecNetIPAM(n, anet, anet.Runtime.IfName)
+ if err2 != nil {
+ return err2
+ }
+
+ default:
+ return fmt.Errorf("network %q have unsupported type: %q", anet.Conf.Name, anet.Conf.Type)
+ }
+
+ return nil
+}
|
@sstabellini Thanks for the feedback; I've made that method public. PTAL. It's not that I dislike xen, it's just that it's a good test-case for making the networking modular :-). |
It works now, without any additional changes on my side. Thank you! One thing though: I don't see XenDelNetwork being called at all. For example, I don't think it gets called when I do `rkt stop'. |
@squeed is away for some days, so I'm moving this to the next milestone. Also assigning @sstabellini for a review once this is fixed, to double-check that everything he needs is in place. |
I'll do, thanks! |
anet.Runtime.IP4.Routes, | ||
cnitypes.Route{Dst: *defaultNet, GW: anet.Runtime.IP4.Gateway}, | ||
) | ||
config.IsGw = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the answer for above question is no - this is unnecessary line, and this if could be merged with next one.
} | ||
ifName := link.Attrs().Name | ||
n.runtime.IfName = ifName | ||
if config.IsGw { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't there be anet.Conf.IsDefaultGateway
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you might be right, good catch.
@sstabellini The network is torn down (and thus XenDelNetwork called) at |
Any progress in this PR? |
@sstabellini ping. |
Hi there, |
This hopefully makes #3695 easier. It also enables cni v0.3 and ipv6.
@sstabellini