Skip to content

Commit

Permalink
Merge pull request #1006 from kubeovn/perf/alias
Browse files Browse the repository at this point in the history
perf: use link alias to filter packet
  • Loading branch information
oilbeater committed Sep 6, 2021
2 parents 8b898e2 + 44a8b4f commit 68e2165
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fastpath/kube_ovn_fastpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ unsigned int hook_func(unsigned int hooknum,
struct udphdr *udp_header = NULL;

// For container network traffic, DO NOT traverse netfilter
if (NULL != in && in->name[13] == 'c' ) { return NF_STOP; }
if (NULL != out && out->name[13] == 'c' ) { return NF_STOP; }
if (NULL != in && NULL != in->ifalias && in->ifalias[13] == 'c' ) { return NF_STOP; }
if (NULL != out && NULL != out->ifalias && out->ifalias[13] == 'c' ) { return NF_STOP; }

if (!skb){
return NF_ACCEPT;
Expand Down
6 changes: 6 additions & 0 deletions pkg/daemon/ovs.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ func configureContainerNic(nicName, ifName string, ipAddr, gateway string, route
return fmt.Errorf("can not find container nic %s: %v", nicName, err)
}

// Set link alias to its origin link name for fastpath to recognize and bypass netfilter
if err := netlink.LinkSetAlias(containerLink, nicName); err != nil {
klog.Errorf("failed to set link alias for container nic %s: %v", nicName, err)
return err
}

if err = netlink.LinkSetNsFd(containerLink, int(netns.Fd())); err != nil {
return fmt.Errorf("failed to link netns: %v", err)
}
Expand Down

0 comments on commit 68e2165

Please sign in to comment.