Skip to content

Commit

Permalink
Disable tso and checksum offload
Browse files Browse the repository at this point in the history
  • Loading branch information
phudtran committed Sep 23, 2020
1 parent 175dbbe commit 54bdab2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 29 deletions.
20 changes: 9 additions & 11 deletions mizar/cni/mizarcni.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@
from pyroute2 import IPRoute, NetNS

logger = logging.getLogger('mizarcni')
logger.setLevel(logging.INFO)
handler = SysLogHandler(address='/dev/log')
handler = logging.FileHandler('/tmp/mizarcni.log')
logger.addHandler(handler)
logger = logging.getLogger()
logger.setLevel(logging.INFO)


class Cni:
Expand Down Expand Up @@ -165,18 +164,17 @@ def activate_interface(self, interface):
prefixlen=int(interface.address.ip_prefix))
iproute_ns.route('add', gateway=interface.address.gateway_ip)

# Disable TSO and checksum offload as xdp currently does not support
logger.info("Disable tso for pod")
cmd = "nsenter -t 1 -m -u -n -i ip netns exec {} ethtool -K {} tso off gso off ufo off".format(
netns, interface.veth.name)
cmd = "ip netns exec {} ethtool -K {} tso off gso off ufo off".format(
netns, "eth0")
rc, text = run_cmd(cmd)
logger.info("Disabled tso rc:{} text{}".format(rc, text))

logger.info("Executed cmd {} tso rc: {} text {}".format(cmd, rc, text))
logger.info("Disable rx tx offload for pod")
cmd = "nsenter -t 1 -m -u -n -i ip netns exec {} ethtool --offload {} rx off tx off".format(
netns, interface.veth.name)
cmd = "ip netns exec {} ethtool --offload {} rx off tx off".format(
netns, "eth0")
rc, text = run_cmd(cmd)
logger.info(
"Disabled rx tx offload for pod rc:{} text{}".format(rc, text))
logger.info("Executed cmd {} rc: {} text {}".format(cmd, rc, text))

def do_delete(self):
param = CniParameters(pod_id=self.pod_id,
Expand Down
7 changes: 6 additions & 1 deletion mizar/daemon/droplet_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
class DropletServer(droplet_pb2_grpc.DropletServiceServicer):

def __init__(self):
self.itf = 'eth0'
cmd = 'ip addr show eth0 | grep "inet\\b" | awk \'{print $2}\' | cut -d/ -f1'
r = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
self.ip = r.stdout.read().decode().strip()
Expand All @@ -27,7 +28,11 @@ def __init__(self):
r = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
self.name = r.stdout.read().decode().strip()

self.itf = 'eth0'
# Disable TSO and checksum offload as xdp currently does not support
cmd = "ethtool -K {} tso off gso off ufo off".format(self.itf)
r = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
cmd = "ethtool --offload {} rx off tx off".format(self.itf)
r = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)

def GetDropletInfo(self, request, context):
droplet = droplet_pb2.Droplet(
Expand Down
19 changes: 3 additions & 16 deletions mizar/daemon/interface_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,20 +246,6 @@ def DeleteInterface(self, request, context):
return empty_pb2.Empty()

def ActivateHostInterface(self, request, context):

# script = (f''' bash -c '\
# nsenter -t 1 -m -u -n -i ip netns add {netns} && \
# nsenter -t 1 -m -u -n -i ip link set {interface.veth.name} netns {netns} && \
# nsenter -t 1 -m -u -n -i ip netns exec {netns} ip addr add {interface.address.ip_address}/{interface.address.ip_prefix} dev {interface.veth.name} && \
# nsenter -t 1 -m -u -n -i ip netns exec {netns} ip link set dev {interface.veth.name} up && \
# nsenter -t 1 -m -u -n -i ip netns exec {netns} sysctl -w net.ipv4.tcp_mtu_probing=2 && \
# nsenter -t 1 -m -u -n -i ip netns exec {netns} ethtool -K {interface.veth.name} tso off gso off ufo off && \
# nsenter -t 1 -m -u -n -i ip netns exec {netns} ethtool --offload {interface.veth.name} rx off tx off && \
# nsenter -t 1 -m -u -n -i ip link set dev {interface.veth.peer} up mtu 9000 && \
# nsenter -t 1 -m -u -n -i ip route add {OBJ_DEFAULTS.default_net_ip}/{OBJ_DEFAULTS.default_net_prefix} dev {interface.veth.name} && \
# nsenter -t 1 -m -u -n -i ip netns exec {netns} route add default gw {interface.address.gateway_ip} && \
# nsenter -t 1 -m -u -n -i ip netns exec {netns} ifconfig lo up' ''')

interface = request

# Provision host veth interface and load transit xdp agent.
Expand All @@ -282,18 +268,19 @@ def ActivateHostInterface(self, request, context):

self.iproute.route('add', dst=OBJ_DEFAULTS.default_net_ip,
mask=int(OBJ_DEFAULTS.default_net_prefix), oif=veth_index)

# Disable TSO and checksum offload as xdp currently does not support
logger.info("Disable tso for host ep")
cmd = "nsenter -t 1 -m -u -n -i ethtool -K {} tso off gso off ufo off".format(
interface.veth.name)
rc, text = run_cmd(cmd)
logger.info("Disabled tso rc:{} text{}".format(rc, text))

logger.info("Disable rx tx offload for host ep")
cmd = "nsenter -t 1 -m -u -n -i ethtool --offload {} rx off tx off".format(
interface.veth.name)
rc, text = run_cmd(cmd)
logger.info(
"Disabled rx tx offload for host ep rc:{} text{}".format(rc, text))
"Disabled rx tx offload for host ep rc: {} text: {}".format(rc, text))
return interface


Expand Down
2 changes: 1 addition & 1 deletion src/xdp/trn_kern.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ static inline void trn_set_src_dst_inner_ip_csum(struct transit_packet *pkt,
pkt->inner_ip->check = csum;

bpf_debug(
"123Modified Inner IP Address, src: 0x%x, dst: 0x%x, csum: 0x%x\n",
"Modified Inner IP Address, src: 0x%x, dst: 0x%x, csum: 0x%x\n",
pkt->inner_ip->saddr, pkt->inner_ip->daddr,
pkt->inner_ip->check);
}
Expand Down

0 comments on commit 54bdab2

Please sign in to comment.