summaryrefslogtreecommitdiffstats
path: root/src/vnet/sr
diff options
context:
space:
mode:
authorPablo Camarillo <pcamaril@cisco.com>2017-03-29 07:54:40 -0700
committerDamjan Marion <dmarion.lists@gmail.com>2017-03-30 12:16:47 +0000
commitadcaaf14012acec9afc3cb6f3738b98d9e9b4c04 (patch)
treee6ea4803081efad66f9d8cb7bae3787a8f3f00ad /src/vnet/sr
parente3d52803149d58737aad38435361e692d70c9d7a (diff)
VPP-673 Fix L2 steering.
Change-Id: I1eab03525f234139ceefbc9b9895a35a03a56910 Signed-off-by: Pablo Camarillo <pcamaril@cisco.com>
Diffstat (limited to 'src/vnet/sr')
-rwxr-xr-xsrc/vnet/sr/sr_steering.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/vnet/sr/sr_steering.c b/src/vnet/sr/sr_steering.c
index be1bb7ade29..1699d888d02 100755
--- a/src/vnet/sr/sr_steering.c
+++ b/src/vnet/sr/sr_steering.c
@@ -72,16 +72,14 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index,
memset (&key, 0, sizeof (sr_steering_key_t));
/* Compute the steer policy key */
- if (prefix)
+ if (traffic_type == SR_STEER_IPV4 || traffic_type == SR_STEER_IPV6)
{
key.l3.prefix.as_u64[0] = prefix->as_u64[0];
key.l3.prefix.as_u64[1] = prefix->as_u64[1];
key.l3.mask_width = mask_width;
key.l3.fib_table = (table_id != (u32) ~ 0 ? table_id : 0);
- if (traffic_type != SR_STEER_IPV4 && traffic_type != SR_STEER_IPV6)
- return -1;
}
- else
+ else if (traffic_type == SR_STEER_L2)
{
key.l2.sw_if_index = sw_if_index;
@@ -94,9 +92,9 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index,
vnet_get_sw_interface (sm->vnet_main, sw_if_index);
if (sw->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
return -3;
- if (traffic_type != SR_STEER_L2)
- return -1;
}
+ else
+ return -1;
key.traffic_type = traffic_type;
@@ -280,8 +278,7 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index,
goto cleanup_error_encap;
if (vnet_feature_enable_disable
- ("device-input", "sr-policy-rewrite-encaps-l2", sw_if_index, 1, 0,
- 0))
+ ("device-input", "sr-pl-rewrite-encaps-l2", sw_if_index, 1, 0, 0))
goto cleanup_error_redirection;
/* Set promiscous mode on interface */
@@ -552,13 +549,18 @@ sr_steering_init (vlib_main_t * vm)
return 0;
}
+/* *INDENT-OFF* */
VLIB_INIT_FUNCTION (sr_steering_init);
+/* *INDENT-ON* */
-VNET_FEATURE_INIT (sr_policy_rewrite_encaps_l2, static) =
+/* *INDENT-OFF* */
+VNET_FEATURE_INIT (sr_pl_rewrite_encaps_l2, static) =
{
-.arc_name = "device-input",.node_name =
- "sr-pl-rewrite-encaps-l2",.runs_before =
- VNET_FEATURES ("ethernet-input"),};
+ .arc_name = "device-input",
+ .node_name = "sr-pl-rewrite-encaps-l2",
+ .runs_before = VNET_FEATURES ("ethernet-input"),
+};
+/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
} /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #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/python
'''
Copyright 2016 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
'''

from cmd import Cmd
import os
import subprocess
import re
import sys
from optparse import OptionParser

try:
        import readline
except ImportError:
        readline = None

persishist = os.path.expanduser('~/.vpphistory')
persishist_size = 1000
if not persishist:
        os.mknod(persishist, stat.S_IFREG)

class Vppctl(Cmd):

        def __init__(self,api_prefix=None):
                Cmd.__init__(self)
                self.api_prefix = api_prefix

        def historyWrite(self):
                if readline:
                        readline.set_history_length(persishist_size)
                        readline.write_history_file(persishist)

        def runVat(self, line):
                input_prefix = "exec "
                input_command = input_prefix + line
                line_remove = '^load_one_plugin:'
                s = '\n'
                if ( self.api_prefix is None):
                        command = ['vpp_api_test']
                else:
                        command = ['vpp_api_test',"chroot prefix %s " % self.api_prefix]

                if os.geteuid() != 0:
                    command = ['sudo'] + command

                vpp_process = subprocess.Popen(command,
                        stderr=subprocess.PIPE,
                        stdin=subprocess.PIPE,
                        stdout=subprocess.PIPE)
                stdout_value = vpp_process.communicate(input_command)[0]

                buffer_stdout = stdout_value.splitlines()

                buffer_stdout[:]  = [b for b in buffer_stdout
                        if line_remove not in b]

                for i, num in enumerate(buffer_stdout):
                        buffer_stdout[i] = num.replace('vat# ','')

                stdout_value = s.join(buffer_stdout)
                print stdout_value

        def do_help(self, line):
                self.runVat("help")

        def default(self, line):
                self.runVat(line)

        def do_exit(self, line):
                self.historyWrite()
                raise SystemExit

        def emptyline(self):
                pass

        def do_EOF(self,line):
                self.historyWrite()
                sys.stdout.write('\n')
                raise SystemExit

        def preloop(self):
                if readline and os.path.exists(persishist):
                        readline.read_history_file(persishist)

        def postcmd(self, stop, line):
                self.historyWrite()

if __name__ == '__main__':
        parser = OptionParser()
        parser.add_option("-p","--prefix",action="store",type="string",dest="prefix")
        (options,command_args) = parser.parse_args(sys.argv)

        if not len(command_args) > 1:
                prompt = Vppctl(options.prefix)
                red_set = '\033[31m'
                norm_set = '\033[0m'
                if sys.stdout.isatty():
                        if(options.prefix is None):
                                prompt.prompt = 'vpp# '
                        else:
                                prompt.prompt = '%s# ' % options.prefix
                        try:
                                prompt.cmdloop(red_set + "    _______    _       " + norm_set + " _   _____  ___ \n" +
                                        red_set + " __/ __/ _ \  (_)__   " + norm_set + " | | / / _ \/ _ \\\n" +
                                        red_set + " _/ _// // / / / _ \\" + norm_set + "   | |/ / ___/ ___/\n" +
                                        red_set + " /_/ /____(_)_/\___/   " + norm_set + "|___/_/  /_/   \n")
                        except KeyboardInterrupt:
                                sys.stdout.write('\n')
                else:
                        try:
                                prompt.cmdloop()
                        except KeyboardInterrupt:
                                sys.stdout.write('\n')
        else:
                del command_args[0]
                stdout_value = " ".join(command_args)
                VatAddress = Vppctl(options.prefix)
                VatAddress.runVat(stdout_value)