Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/systemd/sysconfig.template
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#
# Use KNET interfaces:
# FLAGS_use_knet=true
#
# Mark switched packets as offloaded:
# FLAGS_mark_fwd_offload=true

### glog
#
Expand Down
4 changes: 3 additions & 1 deletion src/baseboxd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ DEFINE_bool(multicast, true, "Enable multicast support");
DEFINE_int32(port, 6653, "Listening port");
DEFINE_int32(ofdpa_grpc_port, 50051, "Listening port of ofdpa gRPC server");
DEFINE_bool(use_knet, true, "Use KNET interfaces");
DEFINE_bool(mark_fwd_offload, true, "Mark switched packets as offloaded");

static bool validate_port(const char *flagname, gflags::int32 value) {
VLOG(3) << __FUNCTION__ << ": flagname=" << flagname << ", value=" << value;
Expand Down Expand Up @@ -48,7 +49,8 @@ int main(int argc, char **argv) {
}

// all variables can be set from env
FLAGS_tryfromenv = std::string("multicast,port,ofdpa_grpc_port,use_knet");
FLAGS_tryfromenv =
std::string("multicast,port,ofdpa_grpc_port,use_knet,mark_fwd_offload");
gflags::SetUsageMessage("");
gflags::SetVersionString(PROJECT_VERSION);

Expand Down
5 changes: 4 additions & 1 deletion src/netlink/cnetlink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "nl_vxlan.h"

DECLARE_bool(multicast);
DECLARE_bool(mark_fwd_offload);

namespace basebox {

Expand Down Expand Up @@ -1352,7 +1353,9 @@ void cnetlink::link_created(rtnl_link *link) noexcept {
} break;
default: {
bool handled = port_man->portdev_ready(link);
if (!handled)
if (handled)
port_man->set_offloaded(link, FLAGS_mark_fwd_offload);
else
LOG(WARNING) << __FUNCTION__ << ": ignoring link with lt=" << lt
<< " link:" << OBJ_CAST(link);
} break;
Expand Down
11 changes: 11 additions & 0 deletions src/netlink/knet_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,15 @@ int knet_manager::set_port_speed(const std::string name, uint32_t speed,
return 1;
}

int knet_manager::set_offloaded(rtnl_link *link, bool offloaded) {
std::string name(rtnl_link_get_name(link));
std::ofstream file("/proc/bcm/knet/link");

if (file.is_open()) {
file << (name + (offloaded ? "=offload" : "=no-offload"));
file.close();
}
return 0;
}

} // namespace basebox
1 change: 1 addition & 0 deletions src/netlink/knet_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class knet_manager final : public port_manager {

int change_port_status(const std::string name, bool status);
int set_port_speed(const std::string name, uint32_t speed, uint8_t duplex);
int set_offloaded(rtnl_link *link, bool offloaded);

// access from northbound (cnetlink)
bool portdev_removed(rtnl_link *link);
Expand Down
1 change: 1 addition & 0 deletions src/netlink/port_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class port_manager {
virtual int change_port_status(const std::string name, bool status) = 0;
virtual int set_port_speed(const std::string name, uint32_t speed,
uint8_t duplex) = 0;
virtual int set_offloaded(rtnl_link *link, bool offloaded) = 0;

// access from northbound (cnetlink)
virtual bool portdev_removed(rtnl_link *link) = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/netlink/tap_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -425,4 +425,6 @@ int tap_manager::set_port_speed(const std::string name, uint32_t speed,
return error;
}

int tap_manager::set_offloaded(rtnl_link *link, bool offloaded) { return 0; }

} // namespace basebox
1 change: 1 addition & 0 deletions src/netlink/tap_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class tap_manager final : public port_manager {

int change_port_status(const std::string name, bool status);
int set_port_speed(const std::string name, uint32_t speed, uint8_t duplex);
int set_offloaded(rtnl_link *link, bool offloaded);

// access from northbound (cnetlink)
bool portdev_removed(rtnl_link *link);
Expand Down