| 3521 | } |
| 3522 | |
| 3523 | func (n *bridge) deleteChildren() error { |
| 3524 | // Get a list of interfaces |
| 3525 | ifaces, err := net.Interfaces() |
| 3526 | if err != nil { |
| 3527 | return err |
| 3528 | } |
| 3529 | |
| 3530 | var externalInterfaces []string |
| 3531 | if n.config["bridge.external_interfaces"] != "" { |
| 3532 | for _, entry := range strings.Split(n.config["bridge.external_interfaces"], ",") { |
| 3533 | entry = strings.Split(strings.TrimSpace(entry), "/")[0] |
| 3534 | externalInterfaces = append(externalInterfaces, entry) |
| 3535 | } |
| 3536 | } |
| 3537 | |
| 3538 | kinds := []string{ |
| 3539 | "vxlan", |
| 3540 | "gretap", |
| 3541 | "dummy", |
| 3542 | } |
| 3543 | |
| 3544 | for _, iface := range ifaces { |
| 3545 | l, err := ip.LinkByName(iface.Name) |
| 3546 | if err != nil { |
| 3547 | // If we can't load the link, chances are the interface isn't one that we should be deleting. |
| 3548 | continue |
| 3549 | } |
| 3550 | |
| 3551 | if l.Master != n.name || slices.Contains(externalInterfaces, iface.Name) || !slices.Contains(kinds, l.Kind) { |
| 3552 | continue |
| 3553 | } |
| 3554 | |
| 3555 | err = l.Delete() |
| 3556 | if err != nil { |
| 3557 | return err |
| 3558 | } |
| 3559 | } |
| 3560 | |
| 3561 | return nil |
| 3562 | } |