|
@@ -70,22 +70,8 @@ func parentExists(ifaceStr string) bool {
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
|
|
|
|
-// vlanLinkExists checks if specified vlan link exists in the default namespace
|
|
|
|
-func vlanLinkExists(linkStr string) bool {
|
|
|
|
- _, err := ns.NlHandle().LinkByName(linkStr)
|
|
|
|
- if err != nil {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// createVlanLink parses sub-interfaces and vlan id for creation
|
|
// createVlanLink parses sub-interfaces and vlan id for creation
|
|
func createVlanLink(parentName string) error {
|
|
func createVlanLink(parentName string) error {
|
|
- if vlanLinkExists(parentName) {
|
|
|
|
- logrus.Debugf("Parent Sub Interface %s already exists", parentName)
|
|
|
|
- return nil
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if strings.Contains(parentName, ".") {
|
|
if strings.Contains(parentName, ".") {
|
|
parent, vidInt, err := parseVlan(parentName)
|
|
parent, vidInt, err := parseVlan(parentName)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -170,22 +156,8 @@ func parseVlan(linkName string) (string, int, error) {
|
|
return parent, vidInt, nil
|
|
return parent, vidInt, nil
|
|
}
|
|
}
|
|
|
|
|
|
-// dummyLinkExists checks if dummylink exists in the default namespace
|
|
|
|
-func dummyLinkExists(dummyName string) bool {
|
|
|
|
- _, err := ns.NlHandle().LinkByName(dummyName)
|
|
|
|
- if err != nil {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// createDummyLink creates a dummy0 parent link
|
|
// createDummyLink creates a dummy0 parent link
|
|
func createDummyLink(dummyName, truncNetID string) error {
|
|
func createDummyLink(dummyName, truncNetID string) error {
|
|
- // check if dummyLinkExists and return if it does
|
|
|
|
- if dummyLinkExists(truncNetID) {
|
|
|
|
- logrus.Debugf("Dummy Link %s for ipvlan already exists", truncNetID)
|
|
|
|
- return nil
|
|
|
|
- }
|
|
|
|
// create a parent interface since one was not specified
|
|
// create a parent interface since one was not specified
|
|
parent := &netlink.Dummy{
|
|
parent := &netlink.Dummy{
|
|
LinkAttrs: netlink.LinkAttrs{
|
|
LinkAttrs: netlink.LinkAttrs{
|