Dobby 3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Loading...
Searching...
No Matches
Functions
BridgeInterface Namespace Reference

A set of functions to setup and bring down a bridge device. The main reason to use these functions separately rather than direct calls to a netlink object from NetworkSetup.cpp is to provide workarounds for libnl versions 3.3.x - 3.4.x. More...

Functions

bool createBridge (const std::shared_ptr< Netlink > &netlink)
 Creates the Dobby bridge device.
 
bool destroyBridge (const std::shared_ptr< Netlink > &netlink)
 Destroys the Dobby bridge device.
 
bool up (const std::shared_ptr< Netlink > &netlink)
 Brings the Dobby bridge device up.
 
bool down (const std::shared_ptr< Netlink > &netlink)
 Brings the Dobby bridge device down.
 
bool setAddresses (const std::shared_ptr< Netlink > &netlink)
 Sets the ip addresses for the bridge device.
 
bool setIfaceForwarding (const std::shared_ptr< DobbyRdkPluginUtils > &utils, const std::shared_ptr< Netlink > &netlink, bool enable)
 Sets forwarding on the Dobby bridge device.
 
bool setIfaceRouteLocalNet (const std::shared_ptr< DobbyRdkPluginUtils > &utils, const std::shared_ptr< Netlink > &netlink, bool enable)
 Sets the route_localnet on the Dobby bridge device.
 
bool setIfaceAcceptRa (const std::shared_ptr< DobbyRdkPluginUtils > &utils, const std::shared_ptr< Netlink > &netlink, int value)
 Sets the accept_ra on the Dobby bridge device.
 
bool disableStp (const std::shared_ptr< DobbyRdkPluginUtils > &utils)
 Disables Spanning Tree Protocol in sysfs file.
 
bool attachLink (const std::shared_ptr< Netlink > &netlink, const std::string &name)
 Attaches an interface to the bridge.
 
std::array< uint8_t, 6 > macAddress (const std::shared_ptr< Netlink > &netlink)
 Gets the MAC address of the interface.
 
bool setMACAddress (const std::shared_ptr< Netlink > &netlink, const std::array< uint8_t, 6 > &address)
 Sets the MAC address of the interface.
 

Detailed Description

A set of functions to setup and bring down a bridge device. The main reason to use these functions separately rather than direct calls to a netlink object from NetworkSetup.cpp is to provide workarounds for libnl versions 3.3.x - 3.4.x.

See also
ENABLE_LIBNL_BRIDGE_WORKAROUND

Function Documentation

◆ attachLink()

bool BridgeInterface::attachLink ( const std::shared_ptr< Netlink > &  netlink,
const std::string &  name 
)

Attaches an interface to the bridge.

Parameters
[in]netlinkInstance of the Netlink class
[in]nameThe name of the interface to attach.
Returns
true on success.

◆ createBridge()

bool BridgeInterface::createBridge ( const std::shared_ptr< Netlink > &  netlink)

Creates the Dobby bridge device.

Parameters
[in]netlinkInstance of the Netlink class.
See also
Netlink::createBridge()
Returns
true on success, false on failure.

◆ destroyBridge()

bool BridgeInterface::destroyBridge ( const std::shared_ptr< Netlink > &  netlink)

Destroys the Dobby bridge device.

Parameters
[in]netlinkInstance of the Netlink class.
See also
Netlink::destroyBridge()
Returns
true on success, false on failure.

◆ disableStp()

bool BridgeInterface::disableStp ( const std::shared_ptr< DobbyRdkPluginUtils > &  utils)

Disables Spanning Tree Protocol in sysfs file.

Parameters
[in]utilsInstance of DobbyRdkPluginUtils
Returns
true on success, false on failure.

◆ down()

bool BridgeInterface::down ( const std::shared_ptr< Netlink > &  netlink)

Brings the Dobby bridge device down.

Uses a workaround function if needed (libnl v3.3.x-3.4.0).

Parameters
[in]netlinkInstance of the Netlink class.
See also
Netlink::ifaceDown()
Returns
true on success, false on failure.

◆ macAddress()

std::array< uint8_t, 6 > BridgeInterface::macAddress ( const std::shared_ptr< Netlink > &  netlink)

Gets the MAC address of the interface.

Parameters
[in]netlinkInstance of the Netlink class
Returns
the MAC address, or a zero address if failed.

◆ setAddresses()

bool BridgeInterface::setAddresses ( const std::shared_ptr< Netlink > &  netlink)

Sets the ip addresses for the bridge device.

This is the equivalent of the following on the command line

ifconfig <BRIDGE_NAME> <address> netmask <netmask>
ifconfig <BRIDGE_NAME> inet6 add <address>/<netmask>
Parameters
[in]netlinkInstance of the Netlink class
Returns
true on success, false on failure.

◆ setIfaceAcceptRa()

bool BridgeInterface::setIfaceAcceptRa ( const std::shared_ptr< DobbyRdkPluginUtils > &  utils,
const std::shared_ptr< Netlink > &  netlink,
int  value 
)

Sets the accept_ra on the Dobby bridge device.

Parameters
[in]utilsInstance of the DobbyRdkPluginUtils class.
[in]netlinkInstance of the Netlink class.
[in]valuevalue to set to accept_ra.
See also
Netlink::setIfaceAcceptRa()
Returns
true on success, false on failure.

◆ setIfaceForwarding()

bool BridgeInterface::setIfaceForwarding ( const std::shared_ptr< DobbyRdkPluginUtils > &  utils,
const std::shared_ptr< Netlink > &  netlink,
bool  enable 
)

Sets forwarding on the Dobby bridge device.

Uses a workaround function if needed (libnl v3.3.x-3.4.0).

Parameters
[in]utilsInstance of the DobbyRdkPluginUtils class.
[in]netlinkInstance of the Netlink class.
[in]enabletrue to enable, false to disable.
See also
Netlink::setIfaceForwarding()
Returns
true on success, false on failure.

◆ setIfaceRouteLocalNet()

bool BridgeInterface::setIfaceRouteLocalNet ( const std::shared_ptr< DobbyRdkPluginUtils > &  utils,
const std::shared_ptr< Netlink > &  netlink,
bool  enable 
)

Sets the route_localnet on the Dobby bridge device.

Uses a workaround function if needed (libnl v3.3.x-3.4.0).

Parameters
[in]utilsInstance of the DobbyRdkPluginUtils class.
[in]netlinkInstance of the Netlink class.
[in]enabletrue to enable, false to disable.
See also
Netlink::setIfaceRouteLocalNet()
Returns
true on success, false on failure.

◆ setMACAddress()

bool BridgeInterface::setMACAddress ( const std::shared_ptr< Netlink > &  netlink,
const std::array< uint8_t, 6 > &  address 
)

Sets the MAC address of the interface.

Parameters
[in]netlinkInstance of the Netlink class
[in]addressThe mac address to set.
Returns
the MAC address, or a zero address if failed.

◆ up()

bool BridgeInterface::up ( const std::shared_ptr< Netlink > &  netlink)

Brings the Dobby bridge device up.

Uses a workaround function if needed (libnl v3.3.x-3.4.0).

Parameters
[in]netlinkInstance of the Netlink class.
See also
Netlink::ifaceUp()
Returns
true on success, false on failure.