summaryrefslogtreecommitdiffstats
path: root/test/test_gtpu.py
blob: 9411fffcf0e6eac178838be635bf9787d85dcde1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#!/usr/bin/env python

import socket
from util import ip4n_range
import unittest
from framework import VppTestCase, VppTestRunner
from template_bd import BridgeDomain

from scapy.layers.l2 import Ether, Raw
from scapy.layers.inet import IP, UDP
from scapy.contrib.gtp import GTP_U_Header
from scapy.utils import atol


class TestGtpu(BridgeDomain, VppTestCase):
    """ GTPU Test Case """

    def __init__(self, *args):
        BridgeDomain.__init__(self)
        VppTestCase.__init__(self, *args)

    def encapsulate(self, pkt, vni):
        """
        Encapsulate the original payload frame by adding GTPU header with its
        UDP, IP and Ethernet fields
        """
        return (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
                IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) /
                UDP(sport=self.dport, dport=self.dport, chksum=0) /
                GTP_U_Header(TEID=vni, gtp_type=self.gtp_type, length=150) /
                pkt)

    def encap_mcast(self, pkt, src_ip, src_mac, vni):
        """
        Encapsulate the original payload frame by adding GTPU header with its
        UDP, IP and Ethernet fields
        """
        return (Ether(src=src_mac, dst=self.mcast_mac) /
                IP(src=src_ip, dst=self.mcast_ip4) /
                UDP(sport=self.dport, dport=self.dport, chksum=0) /
                GTP_U_Header(TEID=vni, gtp_type=self.gtp_type, length=150) /
                pkt)

    def decapsulate(self, pkt):
        """
        Decapsulate the original payload frame by removing GTPU header
        """
        return pkt[GTP_U_Header].payload

    # Method for checking GTPU encapsulation.
    #
    def check_encapsulation(self, pkt, vni, local_only=False, mcast_pkt=False):
        # Verify source MAC is VPP_MAC and destination MAC is MY_MAC resolved
        #  by VPP using ARP.
        self.assertEqual(pkt[Ether].src, self.pg0.local_mac)
        if not local_only:
            if not mcast_pkt:
                self.assertEqual(pkt[Ether].dst, self.pg0.remote_mac)
            else:
                self.assertEqual(pkt[Ether].dst, type(self).mcast_mac)
        # Verify GTPU tunnel source IP is VPP_IP and destination IP is MY_IP.
        self.assertEqual(pkt[IP].src, self.pg0.local_ip4)
        if not local_only:
            if not mcast_pkt:
                self.assertEqual(pkt[IP].dst, self.pg0.remote_ip4)
            else:
                self.assertEqual(pkt[IP].dst, type(self).mcast_ip4)
        # Verify UDP destination port is GTPU 2152, source UDP port could be
        #  arbitrary.
        self.assertEqual(pkt[UDP].dport, type(self).dport)
        # Verify TEID
        self.assertEqual(pkt[GTP_U_Header].TEID, vni)

    def test_encap(self):
        """ Encapsulation test
        Send frames from pg1
        Verify receipt of encapsulated frames on pg0
        """
        self.pg1.add_stream([self.frame_reply])

        self.pg0.enable_capture()

        self.pg_start()

        # Pick first received frame and check if it's corectly encapsulated.
        out = self.pg0.get_capture(1)
        pkt = out[0]
        self.check_encapsulation(pkt, self.single_tunnel_bd)

        # payload = self.decapsulate(pkt)
        # self.assert_eq_pkts(payload, self.frame_reply)

    def test_ucast_flood(self):
        """ Unicast flood test
        Send frames from pg3
        Verify receipt of encapsulated frames on pg0
        """
        self.pg3.add_stream([self.frame_reply])

        self.pg0.enable_capture()

        self.pg_start()

        # Get packet from each tunnel and assert it's corectly encapsulated.
        out = self.pg0.get_capture(self.n_ucast_tunnels)
        for pkt in out:
            self.check_encapsulation(pkt, self.ucast_flood_bd, True)
            # payload = self.decapsulate(pkt)
            # self.assert_eq_pkts(payload, self.frame_reply)

    def test_mcast_flood(self):
        """ Multicast flood test
        Send frames from pg2
        Verify receipt of encapsulated frames on pg0
        """
        self.pg2.add_stream([self.frame_reply])

        self.pg0.enable_capture()

        self.pg_start()

        # Pick first received frame and check if it's corectly encapsulated.
        out = self.pg0.get_capture(1)
        pkt = out[0]
        self.check_encapsulation(pkt, self.mcast_flood_bd,
                                 local_only=False, mcast_pkt=True)

        # payload = self.decapsulate(pkt)
        # self.assert_eq_pkts(payload, self.frame_reply)

    @classmethod
    def create_gtpu_flood_test_bd(cls, teid, n_ucast_tunnels):
        # Create 10 ucast gtpu tunnels under bd
        ip_range_start = 10
        ip_range_end = ip_range_start + n_ucast_tunnels
        next_hop_address = cls.pg0.remote_ip4n
        for dest_ip4n in ip4n_range(next_hop_address, ip_range_start,
                                    ip_range_end):
            # add host route so dest_ip4n will not be resolved
            cls.vapi.ip_add_del_route(dest_ip4n, 32, next_hop_address)
            r = cls.vapi.gtpu_add_del_tunnel(
                src_addr=cls.pg0.local_ip4n,
                dst_addr=dest_ip4n,
                teid=teid)
            cls.vapi.sw_interface_set_l2_bridge(r.sw_if_index, bd_id=teid)

    @classmethod
    def add_del_shared_mcast_dst_load(cls, is_add):
        """
        add or del tunnels sharing the same mcast dst
        to test gtpu ref_count mechanism
        """
        n_shared_dst_tunnels = 20
        teid_start = 1000
        teid_end = teid_start + n_shared_dst_tunnels
        for teid in range(teid_start, teid_end):
            r = cls.vapi.gtpu_add_del_tunnel(
                src_addr=cls.pg0.local_ip4n,
                dst_addr=cls.mcast_ip4n,
                mcast_sw_if_index=1,
                teid=teid,
                is_add=is_add)
            if r.sw_if_index == 0xffffffff:
                raise "bad sw_if_index"

    @classmethod
    def add_shared_mcast_dst_load(cls):
        cls.add_del_shared_mcast_dst_load(is_add=1)

    @classmethod
    def del_shared_mcast_dst_load(cls):
        cls.add_del_shared_mcast_dst_load(is_add=0)

    @classmethod
    def add_del_mcast_tunnels_load(cls, is_add):
        """
        add or del tunnels to test gtpu stability
        """
        n_distinct_dst_tunnels = 20
        ip_range_start = 10
        ip_range_end = ip_range_start + n_distinct_dst_tunnels
        for dest_ip4n in ip4n_range(cls.mcast_ip4n, ip_range_start,
                                    ip_range_end):
            teid = bytearray(dest_ip4n)[3]
            cls.vapi.gtpu_add_del_tunnel(
                src_addr=cls.pg0.local_ip4n,
                dst_addr=dest_ip4n,
                mcast_sw_if_index=1,
                teid=teid,
                is_add=is_add)

    @classmethod
    def add_mcast_tunnels_load(cls):
        cls.add_del_mcast_tunnels_load(is_add=1)

    @classmethod
    def del_mcast_tunnels_load(cls):
        cls.add_del_mcast_tunnels_load(is_add=0)

    # Class method to start the GTPU test case.
    #  Overrides setUpClass method in VppTestCase class.
    #  Python try..except statement is used to ensure that the tear down of
    #  the class will be executed even if exception is raised.
    #  @param cls The class pointer.
    @classmethod
    def setUpClass(cls):
        super(TestGtpu, cls).setUpClass()

        try:
            cls.dport = 2152
            cls.gtp_type = 0xff

            # Create 2 pg interfaces.
            cls.create_pg_interfaces(range(4))
            for pg in cls.pg_interfaces:
                pg.admin_up()

            # Configure IPv4 addresses on VPP pg0.
            cls.pg0.config_ip4()

            # Resolve MAC address for VPP's IP address on pg0.
            cls.pg0.resolve_arp()

            # Our Multicast address
            cls.mcast_ip4 = '239.1.1.1'
            cls.mcast_ip4n = socket.inet_pton(socket.AF_INET, cls.mcast_ip4)
            iplong = atol(cls.mcast_ip4)
            cls.mcast_mac = "01:00:5e:%02x:%02x:%02x" % (
                (iplong >> 16) & 0x7F, (iplong >> 8) & 0xFF, iplong & 0xFF)

            # Create GTPU VTEP on VPP pg0, and put gtpu_tunnel0 and pg1
            #  into BD.
            cls.single_tunnel_bd = 11
            r = cls.vapi.gtpu_add_del_tunnel(
                src_addr=cls.pg0.local_ip4n,
                dst_addr=cls.pg0.remote_ip4n,
                teid=cls.single_tunnel_bd)
            cls.vapi.sw_interface_set_l2_bridge(r.sw_if_index,
                                                bd_id=cls.single_tunnel_bd)
            cls.vapi.sw_interface_set_l2_bridge(cls.pg1.sw_if_index,
                                                bd_id=cls.single_tunnel_bd)

            # Setup teid 2 to test multicast flooding
            cls.n_ucast_tunnels = 10
            cls.mcast_flood_bd = 12
            cls.create_gtpu_flood_test_bd(cls.mcast_flood_bd,
                                          cls.n_ucast_tunnels)
            r = cls.vapi.gtpu_add_del_tunnel(
                src_addr=cls.pg0.local_ip4n,
                dst_addr=cls.mcast_ip4n,
                mcast_sw_if_index=1,
                teid=cls.mcast_flood_bd)
            cls.vapi.sw_interface_set_l2_bridge(r.sw_if_index,
                                                bd_id=cls.mcast_flood_bd)
            cls.vapi.sw_interface_set_l2_bridge(cls.pg2.sw_if_index,
                                                bd_id=cls.mcast_flood_bd)

            # Add and delete mcast tunnels to check stability
            cls.add_shared_mcast_dst_load()
            cls.add_mcast_tunnels_load()
            cls.del_shared_mcast_dst_load()
            cls.del_mcast_tunnels_load()

            # Setup teid 3 to test unicast flooding
            cls.ucast_flood_bd = 13
            cls.create_gtpu_flood_test_bd(cls.ucast_flood_bd,
                                          cls.n_ucast_tunnels)
            cls.vapi.sw_interface_set_l2_bridge(cls.pg3.sw_if_index,
                                                bd_id=cls.ucast_flood_bd)
        except Exception:
            super(TestGtpu, cls).tearDownClass()
            raise

    # Method to define VPP actions before tear down of the test case.
    #  Overrides tearDown method in VppTestCase class.
    #  @param self The object pointer.
    def tearDown(self):
        super(TestGtpu, self).tearDown()
        if not self.vpp_dead:
            self.logger.info(self.vapi.cli("show bridge-domain 11 detail"))
            self.logger.info(self.vapi.cli("show bridge-domain 12 detail"))
            self.logger.info(self.vapi.cli("show bridge-domain 13 detail"))
            self.logger.info(self.vapi.cli("show int"))
            self.logger.info(self.vapi.cli("show gtpu tunnel"))
            self.logger.info(self.vapi.cli("show trace"))


if __name__ == '__main__':
    unittest.main(testRunner=VppTestRunner)
="mi">1; vlib_process_suspend (vm, 2.0); while (um->unix_config_complete == 0) vlib_process_suspend (vm, 0.1); if (um->startup_config_filename) { unformat_input_t sub_input; int fd; struct stat s; char *fn = (char *) um->startup_config_filename; fd = open (fn, O_RDONLY); if (fd < 0) { clib_warning ("failed to open `%s'", fn); return 0; } if (fstat (fd, &s) < 0) { clib_warning ("failed to stat `%s'", fn); bail: close (fd); return 0; } if (!(S_ISREG (s.st_mode) || S_ISLNK (s.st_mode))) { clib_warning ("not a regular file: `%s'", fn); goto bail; } while (n > 0) { l = vec_len (buf); vec_resize (buf, 4096); n = read (fd, buf + l, 4096); if (n > 0) { _vec_len (buf) = l + n; if (n < 4096) break; } else break; } if (um->log_fd && vec_len (buf)) { u8 *lv = 0; lv = format (lv, "%U: ***** Startup Config *****\n%v", format_timeval, 0 /* current bat-time */ , 0 /* current bat-format */ , buf); { int rv __attribute__ ((unused)) = write (um->log_fd, lv, vec_len (lv)); } vec_reset_length (lv); lv = format (lv, "%U: ***** End Startup Config *****\n", format_timeval, 0 /* current bat-time */ , 0 /* current bat-format */ ); { int rv __attribute__ ((unused)) = write (um->log_fd, lv, vec_len (lv)); } vec_free (lv); } if (vec_len (buf)) { unformat_init_vector (&sub_input, buf); vlib_cli_input (vm, &sub_input, 0, 0); /* frees buf for us */ unformat_free (&sub_input); } close (fd); } return 0; } /* *INDENT-OFF* */ VLIB_REGISTER_NODE (startup_config_node,static) = { .function = startup_config_process, .type = VLIB_NODE_TYPE_PROCESS, .name = "startup-config-process", .process_log2_n_stack_bytes = 18, }; /* *INDENT-ON* */ static clib_error_t * unix_config (vlib_main_t * vm, unformat_input_t * input) { vlib_global_main_t *vgm = vlib_get_global_main (); unix_main_t *um = &unix_main; clib_error_t *error = 0; gid_t gid; int pidfd = -1; /* Defaults */ um->cli_pager_buffer_limit = UNIX_CLI_DEFAULT_PAGER_LIMIT; um->cli_history_limit = UNIX_CLI_DEFAULT_HISTORY; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { char *cli_prompt; if (unformat (input, "interactive")) um->flags |= UNIX_FLAG_INTERACTIVE; else if (unformat (input, "nodaemon")) um->flags |= UNIX_FLAG_NODAEMON; else if (unformat (input, "nosyslog")) um->flags |= UNIX_FLAG_NOSYSLOG; else if (unformat (input, "nocolor")) um->flags |= UNIX_FLAG_NOCOLOR; else if (unformat (input, "nobanner")) um->flags |= UNIX_FLAG_NOBANNER; else if (unformat (input, "cli-prompt %s", &cli_prompt)) vlib_unix_cli_set_prompt (cli_prompt); else if (unformat (input, "cli-listen %s", &um->cli_listen_socket.config)) ; else if (unformat (input, "runtime-dir %s", &um->runtime_dir)) ; else if (unformat (input, "cli-line-mode")) um->cli_line_mode = 1; else if (unformat (input, "cli-no-banner")) um->cli_no_banner = 1; else if (unformat (input, "cli-no-pager")) um->cli_no_pager = 1; else if (unformat (input, "poll-sleep-usec %d", &um->poll_sleep_usec)) ; else if (unformat (input, "cli-pager-buffer-limit %d", &um->cli_pager_buffer_limit)) ; else if (unformat (input, "cli-history-limit %d", &um->cli_history_limit)) ; else if (unformat (input, "coredump-size")) { uword coredump_size = 0; if (unformat (input, "unlimited")) { coredump_size = RLIM_INFINITY; } else if (!unformat (input, "%U", unformat_memory_size, &coredump_size)) { return clib_error_return (0, "invalid coredump-size parameter `%U'", format_unformat_error, input); } const struct rlimit new_limit = { coredump_size, coredump_size }; if (0 != setrlimit (RLIMIT_CORE, &new_limit)) { clib_unix_warning ("prlimit() failed"); } } else if (unformat (input, "full-coredump")) { int fd; fd = open ("/proc/self/coredump_filter", O_WRONLY); if (fd >= 0) { if (write (fd, "0x6f\n", 5) != 5) clib_unix_warning ("coredump filter write failed!"); close (fd); } else clib_unix_warning ("couldn't open /proc/self/coredump_filter"); } else if (unformat (input, "startup-config %s", &um->startup_config_filename)) ; else if (unformat (input, "exec %s", &um->startup_config_filename)) ; else if (unformat (input, "log %s", &um->log_filename)) { um->log_fd = open ((char *) um->log_filename, O_CREAT | O_WRONLY | O_APPEND, 0644); if (um->log_fd < 0) { clib_warning ("couldn't open log '%s'\n", um->log_filename); um->log_fd = 0; } else { u8 *lv = 0; lv = format (0, "%U: ***** Start: PID %d *****\n", format_timeval, 0 /* current bat-time */ , 0 /* current bat-format */ , getpid ()); { int rv __attribute__ ((unused)) = write (um->log_fd, lv, vec_len (lv)); } vec_free (lv); } } else if (unformat (input, "gid %U", unformat_unix_gid, &gid)) { if (setegid (gid) == -1) return clib_error_return_unix (0, "setegid"); } else if (unformat (input, "pidfile %s", &um->pidfile)) ; else return clib_error_return (0, "unknown input `%U'", format_unformat_error, input); } if (um->runtime_dir == 0) { uid_t uid = geteuid (); if (uid == 00) um->runtime_dir = format (0, "/run/%s%c", vlib_default_runtime_dir, 0); else um->runtime_dir = format (0, "/run/user/%u/%s%c", uid, vlib_default_runtime_dir, 0); } /* Ensure the runtime directory is created */ error = vlib_unix_recursive_mkdir ((char *) um->runtime_dir); if (error) return error; error = setup_signal_handlers (um); if (error) return error; if (um->pidfile) { if ((error = vlib_unix_validate_runtime_file (um, (char *) um->pidfile, &um->pidfile))) return error; if (((pidfd = open ((char *) um->pidfile, O_CREAT | O_WRONLY | O_TRUNC, 0644)) < 0)) { return clib_error_return_unix (0, "open"); } } if (!(um->flags & (UNIX_FLAG_INTERACTIVE | UNIX_FLAG_NOSYSLOG))) { openlog (vgm->name, LOG_CONS | LOG_PERROR | LOG_PID, LOG_DAEMON); clib_error_register_handler (unix_error_handler, um); if (!(um->flags & UNIX_FLAG_NODAEMON) && daemon ( /* chdir to / */ 0, /* stdin/stdout/stderr -> /dev/null */ 0) < 0) clib_error_return (0, "daemon () fails"); } if (pidfd >= 0) { u8 *lv = format (0, "%d", getpid ()); if (write (pidfd, (char *) lv, vec_len (lv)) != vec_len (lv)) { vec_free (lv); close (pidfd); return clib_error_return_unix (0, "write"); } vec_free (lv); close (pidfd); } um->unix_config_complete = 1; return 0; } /* unix { ... } configuration. */ /*? * * @cfgcmd{interactive} * Attach CLI to stdin/out and provide a debugging command line interface. * Implies @c nodaemon. * * @cfgcmd{nodaemon} * Do not fork or background the VPP process. Typically used when invoking * VPP applications from a process monitor. * * @cfgcmd{nosyslog} * Do not send e.g. clib_warning(...) output to syslog. Used * when invoking VPP applications from a process monitor which * pipe stdout/stderr to a dedicated logger service. * * @cfgcmd{nocolor} * Do not use colors in outputs. * * * @cfgcmd{nobanner} * Do not display startup banner. * * @cfgcmd{exec, &lt;filename&gt;} * @par <code>startup-config &lt;filename&gt;</code> * Read startup operational configuration from @c filename. * The contents of the file will be performed as though entered at the CLI. * The two keywords are aliases for the same function; if both are specified, * only the last will have an effect. * * @cfgcmd{log, &lt;filename&gt;} * Logs the startup configuration and all subsequent CLI commands in * @c filename. * Very useful in situations where folks don't remember or can't be bothered * to include CLI commands in bug reports. * * @cfgcmd{pidfile, &lt;filename&gt;} * Writes the pid of the main thread in @c filename. * * @cfgcmd{full-coredump} * Ask the Linux kernel to dump all memory-mapped address regions, instead * of just text+data+bss. * * @cfgcmd{runtime-dir} * Define directory where VPP is going to store all runtime files. * Default is /run/vpp when running as root, /run/user/<UID>/vpp if running as * an unprivileged user. * * @cfgcmd{cli-listen, &lt;address:port&gt;} * Bind the CLI to listen at the address and port given. @c localhost * on TCP port @c 5002, given as <tt>cli-listen localhost:5002</tt>, * is typical. * * @cfgcmd{cli-line-mode} * Disable character-by-character I/O on stdin. Useful when combined with, * for example, <tt>emacs M-x gud-gdb</tt>. * * @cfgcmd{cli-prompt, &lt;string&gt;} * Configure the CLI prompt to be @c string. * * @cfgcmd{cli-history-limit, &lt;nn&gt;} * Limit command history to @c nn lines. A value of @c 0 * disables command history. Default value: @c 50 * * @cfgcmd{cli-no-banner} * Disable the login banner on stdin and Telnet connections. * * @cfgcmd{cli-no-pager} * Disable the output pager. * * @cfgcmd{cli-pager-buffer-limit, &lt;nn&gt;} * Limit pager buffer to @c nn lines of output. * A value of @c 0 disables the pager. Default value: @c 100000 * * @cfgcmd{gid, &lt;nn&gt;} * Set the effective gid under which the vpp process is to run. * * @cfgcmd{poll-sleep-usec, &lt;nn&gt;} * Set a fixed poll sleep interval between main loop polls. ?*/ VLIB_EARLY_CONFIG_FUNCTION (unix_config, "unix"); static clib_error_t * unix_exit (vlib_main_t * vm) { /* Close syslog connection. */ closelog (); return 0; } VLIB_MAIN_LOOP_EXIT_FUNCTION (unix_exit); u8 **vlib_thread_stacks; static uword thread0 (uword arg) { vlib_main_t *vm = (vlib_main_t *) arg; unformat_input_t input; int i; vlib_process_finish_switch_stack (vm); unformat_init_command_line (&input, (char **) vm->argv); i = vlib_main (vm, &input); unformat_free (&input); return i; } u8 * vlib_thread_stack_init (uword thread_index) { void *stack; ASSERT (thread_index < vec_len (vlib_thread_stacks)); stack = clib_mem_vm_map_stack (VLIB_THREAD_STACK_SIZE, CLIB_MEM_PAGE_SZ_DEFAULT, "thread stack: thread %u", thread_index); if (stack == CLIB_MEM_VM_MAP_FAILED) clib_panic ("failed to allocate thread %u stack", thread_index); vlib_thread_stacks[thread_index] = stack; return stack; } int vlib_unix_main (int argc, char *argv[]) { vlib_global_main_t *vgm = vlib_get_global_main (); vlib_main_t *vm = vlib_get_first_main (); /* one and only time for this! */ unformat_input_t input; clib_error_t *e; int i; vec_validate_aligned (vgm->vlib_mains, 0, CLIB_CACHE_LINE_BYTES); vm->argv = (u8 **) argv; vgm->name = argv[0]; vm->heap_base = clib_mem_get_heap (); vm->heap_aligned_base = (void *) (((uword) vm->heap_base) & ~(CLIB_CACHE_LINE_BYTES - 1)); ASSERT (vm->heap_base); clib_time_init (&vm->clib_time); /* Turn on the event logger at the first possible moment */ vgm->configured_elog_ring_size = 128 << 10; elog_init (vlib_get_elog_main (), vgm->configured_elog_ring_size); elog_enable_disable (vlib_get_elog_main (), 1); unformat_init_command_line (&input, (char **) vm->argv); if ((e = vlib_plugin_config (vm, &input))) { clib_error_report (e); return 1; } unformat_free (&input); i = vlib_plugin_early_init (vm); if (i) return i; unformat_init_command_line (&input, (char **) vm->argv); if (vgm->init_functions_called == 0) vgm->init_functions_called = hash_create (0, /* value bytes */ 0); e = vlib_call_all_config_functions (vm, &input, 1 /* early */ ); if (e != 0) { clib_error_report (e); return 1; } unformat_free (&input); /* always load symbols, for signal handler and mheap memory get/put backtrace */ clib_elf_main_init (vgm->name); vec_validate (vlib_thread_stacks, 0); vlib_thread_stack_init (0); __os_thread_index = 0; vm->thread_index = 0; vlib_process_start_switch_stack (vm, 0); i = clib_calljmp (thread0, (uword) vm, (void *) (vlib_thread_stacks[0] + VLIB_THREAD_STACK_SIZE)); return i; } /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */