summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorMichael Yu <michael.a.yu@nokia-sbell.com>2019-08-30 00:50:16 +0800
committerDamjan Marion <dmarion@me.com>2019-08-30 13:18:24 +0000
commit90b34ed67a516c4391ad353ba431f8419b582d50 (patch)
tree0afeecc696ecca3bba3b85486b91bb75266448f1 /src/vnet
parent182d2198332c2a20891a7cdbceeaaf62b47924e8 (diff)
devices: fix issue of per_interface_next_index
Per interface, next hop graph node can be customized with vnet_hw_interface_rx_redirect_to_node function, but it doesn't work well for af-packet type interface. In current implementation, with function af_packet_set_interface_next_node invoked next hop graph node index can be set to apif->per_interface_next_index, but it's not set to next0 properly for packet processing in af_packet_device_input_fn. Type: fix Signed-off-by: Michael Yu <michael.a.yu@nokia-sbell.com> Change-Id: I8e132ddd1c3c01b6f476de78546d4a9389b3ff87 Signed-off-by: Michael Yu <michael.a.yu@nokia-sbell.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/devices/af_packet/node.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/vnet/devices/af_packet/node.c b/src/vnet/devices/af_packet/node.c
index 3c91c981618..85f3e0118cf 100644
--- a/src/vnet/devices/af_packet/node.c
+++ b/src/vnet/devices/af_packet/node.c
@@ -195,9 +195,6 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
u32 n_buffer_bytes = vlib_buffer_get_default_data_size (vm);
u32 min_bufs = apif->rx_req->tp_frame_size / n_buffer_bytes;
- if (apif->per_interface_next_index != ~0)
- next_index = apif->per_interface_next_index;
-
n_free_bufs = vec_len (apm->rx_buffers[thread_index]);
if (PREDICT_FALSE (n_free_bufs < VLIB_FRAME_SIZE))
{
@@ -302,6 +299,10 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
else
{
next0 = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
+
+ if (PREDICT_FALSE (apif->per_interface_next_index != ~0))
+ next0 = apif->per_interface_next_index;
+
/* redirect if feature path enabled */
vnet_feature_start_device_input_x1 (apif->sw_if_index, &next0,
first_b0);
or: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#!/usr/bin/env python3

import unittest

from framework import VppTestCase, VppTestRunner, running_extended_tests
from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
import os


class TestMpcap(VppTestCase):
    """ Mpcap Unit Test Cases """

    @classmethod
    def setUpClass(cls):
        super(TestMpcap, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(TestMpcap, cls).tearDownClass()

    def setUp(self):
        super(TestMpcap, self).setUp()

    def tearDown(self):
        super(TestMpcap, self).tearDown()

    def test_mpcap_unittest(self):
        """ Mapped pcap file test """
        cmds = ["packet-generator new {\n"
                " name mpcap\n"
                " limit 15\n"
                " size 128-128\n"
                " interface local0\n"
                " node mpcap-unittest\n"
                " data {\n"
                "   IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n"
                "   ICMP: db00::1 -> db00::2\n"
                "   incrementing 30\n"
                "   }\n",
                "trace add pg-input 15",
                "pa en",
                "show trace",
                "show error"]

        for cmd in cmds:
            self.logger.info(self.vapi.cli(cmd))

        size = os.path.getsize("/tmp/mpcap_unittest.pcap")
        os.remove("/tmp/mpcap_unittest.pcap")
        if size != 2184:
            self.logger.critical("BUG: file size %d not 2184" % size)
            self.assertNotIn('WrongMPCAPFileSize', 'WrongMPCAPFileSize')

if __name__ == '__main__':
    unittest.main(testRunner=VppTestRunner)