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

bridge: add vlan trunk support #689

Closed

Conversation

tjjh89017
Copy link

@tjjh89017 tjjh89017 commented Jan 11, 2022

add vlan trunk support for veth
vlan trunk only support L2 only mode without any IPAM
refer ovs-cni design
https://github.com/k8snetworkplumbingwg/ovs-cni/blob/main/pkg/plugin/plugin.go

design:
origin "vlan" option will be PVID or untagged vlan for the network.
"vlanTrunk" will setup tagged vlan for veth.

entry type:
{ "id": 100 } will specify only tagged vlan 100
{ "minID": 100, "maxID": 120 } will specify tagged vlan from 100 to
120 (include 100 and 120)
vlanTrunk is a list of above entry type, so you can use this to add
tagged vlan
[ { "id": 100 }, { "minID": 1000, "maxID": 2000 } ]

complete config will be like this

{
  "cniVersion": "0.3.1",
  "name": "mynet",
  "type": "bridge",
  "bridge": "mynet0",
  "vlan": 100,
  "vlanTrunk": [
    { "id": 101 },
    { "minID": 1000, "maxID": 2000 },
    { "minID": 3000, "maxID": 4000 }
  ],
  "ipam": {}
}

Signed-off-by: Date Huang date.huang@suse.com

@tjjh89017
Copy link
Author

@dcbw could you take a look on it.
thanks a lot!

@squeed
Copy link
Member

squeed commented Feb 9, 2022

This is interesting. We had a question in the maintainers' meeting: how do you receive the packets inside the container? Are you using another process to create vlan-tagged interfaces inside? Or are you doing it in userspace?

@squeed
Copy link
Member

squeed commented Feb 9, 2022

Another comment (mostly from @dcbw) -- is trunking a per-port setting? Is it possible / desired for different containers on the same bridge to have different trunking configurations?

@tjjh89017
Copy link
Author

tjjh89017 commented Feb 10, 2022

This is interesting. We had a question in the maintainers' meeting: how do you receive the packets inside the container? Are you using another process to create vlan-tagged interfaces inside? Or are you doing it in userspace?

In our scenario, kubevirt will setup another bridge to catch all traffic and let VM handle the VLAN tag
userspace program also could handle vlan tag with NET_RAW.
we also create vlan interface to filter vlan tag also.

Another comment (mostly from @dcbw) -- is trunking a per-port setting? Is it possible / desired for different containers on the same bridge to have different trunking configurations?

Per port, yes!
it probably needs multus or some other CNI to help.
for example, you can add different network attached definition to different container.
this vlan trunk's behavior is same as "vlan" entry in original bridge cni support

linux equivalent command:

ip link add br0 type bridge vlan_filtering 1
ip link set br0 up
ip link set eth0 master br0
ip link add veth-red type veth peer name veth-blue
ip link set veth-red master br0
ip link set veth-red up
ip link add veth-green veth peer name veth-purple
ip link set veth-green master br0
ip link set veth-green up

birdge vlan add dev veth-red vid 100 pvid untagged
bridge vlan add dev veth-red vid 101
bridge vlan add dev veth-red vid 102

bridge vlan add dev veth-green vid 200 pvid untagged
bridge vlan add dev veth-green vid 201
bridge vlan add dev veth-green vid 202

@tjjh89017 tjjh89017 requested a review from squeed February 14, 2022 05:54
@dcbw
Copy link
Member

dcbw commented Mar 2, 2022

@tjjh89017 could you rebase since we merged a fix for ipamDel()? Thanks!

@tjjh89017 tjjh89017 force-pushed the bridge_vlan_trunk branch from ea3a18d to 63adec5 Compare March 3, 2022 02:08
@tjjh89017 tjjh89017 requested a review from dcbw March 3, 2022 03:47
add vlan trunk support for veth
vlan trunk only support L2 only mode without any IPAM
refer ovs-cni design
https://github.com/k8snetworkplumbingwg/ovs-cni/blob/main/pkg/plugin/plugin.go

design:
origin "vlan" option will be PVID or untagged vlan for the network.
"vlanTrunk" will setup tagged vlan for veth.

entry type:
`{ "id": 100 }` will specify only tagged vlan 100
`{ "minID": 100, "maxID": 120 }` will specify tagged vlan from 100 to
120 (include 100 and 120)
vlanTrunk is a list of above entry type, so you can use this to add
tagged vlan
`[
  { "id": 100 },
  {
    "minID": 1000,
    "maxID": 2000
  }
]`

complete config will be like this
{
  "cniVersion": "0.3.1",
  "name": "mynet",
  "type": "bridge",
  "bridge": "mynet0",
  "vlan": 100,
  "vlanTrunk": [
    { "id": 101 },
    { "minID": 1000, "maxID": 2000 },
    { "minID": 3000, "maxID": 4000 }
  ],
  "ipam": {}
}

Signed-off-by: Date Huang <date.huang@suse.com>
@tjjh89017 tjjh89017 force-pushed the bridge_vlan_trunk branch from f7ba457 to d3272b4 Compare March 3, 2022 03:52
@tjjh89017
Copy link
Author

tjjh89017 commented Mar 3, 2022

@dcbw tks for help
already rebased it.
need your double check again and approve.

@github-actions
Copy link

github-actions bot commented May 9, 2022

This PR has been untouched for too long without an update. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label May 9, 2022
@tjjh89017
Copy link
Author

@dcbw do we have any plan to support this feature?
thanks a lot

@github-actions github-actions bot removed the Stale label May 10, 2022
@github-actions
Copy link

github-actions bot commented Jul 9, 2022

This PR has been untouched for too long without an update. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jul 9, 2022
Comment on lines +113 to +114
var err error
if n.vlans, err = collectVlanTrunk(n.VlanTrunk); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be more consistent with the rest of the code to use the scoped variable and not define err?

Copy link
Author

Choose a reason for hiding this comment

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

We will still need to copy the value back to n.vlans later.
So I will consider to keep current code

plugins/main/bridge/bridge.go Show resolved Hide resolved
@github-actions github-actions bot closed this Jul 23, 2022
@tjjh89017
Copy link
Author

@dcbw @squeed Hi
Our project will still need this enhancement.
Could you guys give us some comment for this feature?
thanks a lot

@bk201
Copy link

bk201 commented Aug 18, 2022

Please help reopen the issue. We still need this enhancement.

@squeed
Copy link
Member

squeed commented Feb 13, 2023

Arg, I somehow can't reopen. I'm sorry. Can you resubmit?

@tjjh89017
Copy link
Author

tjjh89017 commented Feb 13, 2023

@squeed I will create a new PR for this commit.
I will link to here later.

New PR: #829

@tjjh89017
Copy link
Author

I opened a new PR and rebase it again.
Please check the new PR number #829
Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants