func (engine *engine) createBridge(bridgeName string, mtu int) error {
	bridgeLinkAttributes := netlink.NewLinkAttrs()
	bridgeLinkAttributes.MTU = mtu
	bridgeLinkAttributes.Name = bridgeName
	bridge := &netlink.Bridge{
		LinkAttrs: bridgeLinkAttributes,
	}
	err := engine.netLink.LinkAdd(bridge)
	if err != nil {
		return errors.Wrapf(err,
			"bridge create: unable to add bridge interface %s", bridgeName)
	}
	return nil
}
createBridge creates a bridge interface
package engine
import (
	"net"
	"strings"
	"syscall"
	"github.com/aws/amazon-ecs-cni-plugins/pkg/cniipamwrapper"
	"github.com/aws/amazon-ecs-cni-plugins/pkg/cniipwrapper"
	"github.com/aws/amazon-ecs-cni-plugins/pkg/cninswrapper"
	"github.com/aws/amazon-ecs-cni-plugins/pkg/netlinkwrapper"
	"github.com/containernetworking/cni/pkg/types/current"
	"github.com/pkg/errors"
	"github.com/vishvananda/netlink"
)
const  (
	zeroLengthIPString = "<nil>"
	fileExistsErrMsg = "file exists"
)
type Engine interface {
	CreateBridge(bridgeName string, mtu int) (*netlink.Bridge, error)
	CreateVethPair(netnsName string, mtu int, interfaceName string) (*current.Interface, string, error)
	AttachHostVethInterfaceToBridge(hostVethName string, bridge *netlink.Bridge) (*current.Interface, error)
	RunIPAMPluginAdd(plugin string, netConf []byte) (*current.Result, error)
	ConfigureContainerVethInterface(netnsName string, result *current.Result, interfaceName string) error
	ConfigureBridge(result *current.Result, bridge *netlink.Bridge) error
	GetInterfaceIPV4Address(netnsName string, interfaceName string) (string, error)
	RunIPAMPluginDel(plugin string, netconf []byte) error
	DeleteVeth(netnsName string, interfaceName string) error
}
type engine struct {
	netLink netlinkwrapper.NetLink
	ns      cninswrapper.NS
	ip      cniipwrapper.IP
	ipam    cniipamwrapper.IPAM
}
func New() Engine {
	return &engine{
		netLink: netlinkwrapper.NewNetLink(),
		ns:      cninswrapper.NewNS(),
		ip:      cniipwrapper.New(),
		ipam:    cniipamwrapper.New(),
	}
}
func (engine *engine) CreateBridge(bridgeName string, mtu int) (*netlink.Bridge, error) {
	bridge, err := engine.lookupBridge(bridgeName)
	if err != nil {
		return nil, err
	}
	if bridge == nil {
		err = engine.createBridge(bridgeName, mtu)
		if err != nil {
			if !strings.Contains(err.Error(), fileExistsErrMsg) {
				return nil, err
			}
		}
		bridge, err = engine.lookupBridge(bridgeName)
		if err != nil {
			return nil, err
		}
	}
	if err := engine.netLink.LinkSetUp(bridge); err != nil {
		return nil, errors.Wrapf(err,
			"bridge create: unable to bring up the bridge interface %s", bridgeName)
	}
	return bridge, nil
}
func (engine *engine) lookupBridge(bridgeName string) (*netlink.Bridge, error) {
	bridgeLink, err := engine.netLink.LinkByName(bridgeName)
	if err != nil {
		if _, ok := err.(netlink.LinkNotFoundError); !ok {
			return nil, errors.Wrapf(err,
				"bridge create: error lookup the bridge interface %s", bridgeName)
		}
		return nil, nil
	}
	bridge, ok := bridgeLink.(*netlink.Bridge)
	if !ok {
		return nil, errors.Errorf(
			"bridge create: interface named %s already exists, but is not a bridge",
			bridgeName)
	}
	return bridge, nil
}