• David Ahern's avatar
    net: vrf: performance improvements for IPv6 · a9ec54d1
    David Ahern authored
    The VRF driver allows users to implement device based features for an
    entire domain. For example, a qdisc or netfilter rules can be attached
    to a VRF device or tcpdump can be used to view packets for all devices
    in the L3 domain.
    
    The device-based features come with a performance penalty, most
    notably in the Tx path. The VRF driver uses the l3mdev_l3_out hook
    to switch the dst on an skb to its private dst. This allows the skb
    to traverse the xmit stack with the device set to the VRF device
    which in turn enables the netfilter and qdisc features. The VRF
    driver then performs the FIB lookup again and reinserts the packet.
    
    This patch avoids the redirect for IPv6 packets if a qdisc has not
    been attached to a VRF device which is the default config. In this
    case the netfilter hooks and network taps are directly traversed in
    the l3mdev_l3_out handler. If a qdisc is attached to a VRF device,
    then the redirect using the vrf dst is done.
    
    Additional overhead is removed by only checking packet taps if a
    socket is open on the device (vrf_dev->ptype_all list is not empty).
    Packet sockets bound to any device will still get a copy of the
    packet via the real ingress or egress interface.
    
    The end result of this change is a decrease in the overhead of VRF
    for the default, baseline case (ie., no netfilter rules, no packet
    sockets, no qdisc) from a +3% improvement for UDP which has a lookup
    per packet (VRF being better than no l3mdev) to ~2% loss for TCP_CRR
    which connects a socket for each request-response.
    Signed-off-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    a9ec54d1
vrf.c 34.3 KB