2 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <arpa/inet.h>
21 #include <sys/socket.h>
23 #include <netinet/in.h>
29 #include "command-line.h"
35 #include "openvswitch/dynamic-string.h"
37 #include "openvswitch/match.h"
39 #include "netdev-dpdk.h"
42 #include "openvswitch/ofpbuf.h"
44 #include "openvswitch/shash.h"
51 #include "openvswitch/ofp-parse.h"
53 typedef int dpctl_command_handler(int argc
, const char *argv
[],
54 struct dpctl_params
*);
55 struct dpctl_command
{
60 dpctl_command_handler
*handler
;
61 enum { DP_RO
, DP_RW
} mode
;
63 static const struct dpctl_command
*get_all_dpctl_commands(void);
64 static void dpctl_print(struct dpctl_params
*dpctl_p
, const char *fmt
, ...)
65 OVS_PRINTF_FORMAT(2, 3);
66 static void dpctl_error(struct dpctl_params
* dpctl_p
, int err_no
,
68 OVS_PRINTF_FORMAT(3, 4);
71 dpctl_puts(struct dpctl_params
*dpctl_p
, bool error
, const char *string
)
73 dpctl_p
->output(dpctl_p
->aux
, error
, string
);
77 dpctl_print(struct dpctl_params
*dpctl_p
, const char *fmt
, ...)
83 string
= xvasprintf(fmt
, args
);
86 dpctl_puts(dpctl_p
, false, string
);
91 dpctl_error(struct dpctl_params
* dpctl_p
, int err_no
, const char *fmt
, ...)
93 const char *subprogram_name
= get_subprogram_name();
94 struct ds ds
= DS_EMPTY_INITIALIZER
;
95 int save_errno
= errno
;
99 if (subprogram_name
[0]) {
100 ds_put_format(&ds
, "%s(%s): ", program_name
,subprogram_name
);
102 ds_put_format(&ds
, "%s: ", program_name
);
106 ds_put_format_valist(&ds
, fmt
, args
);
110 ds_put_format(&ds
, " (%s)", ovs_retval_to_string(err_no
));
112 ds_put_cstr(&ds
, "\n");
114 dpctl_puts(dpctl_p
, true, ds_cstr(&ds
));
121 static int dpctl_add_if(int argc
, const char *argv
[], struct dpctl_params
*);
124 if_up(struct netdev
*netdev
)
126 return netdev_turn_flags_on(netdev
, NETDEV_UP
, NULL
);
129 /* Retrieve the name of the datapath if exactly one exists. The caller
130 * is responsible for freeing the returned string. If there is not one
131 * datapath, aborts with an error message. */
133 get_one_dp(struct dpctl_params
*dpctl_p
)
137 char *dp_name
= NULL
;
141 dp_enumerate_types(&types
);
142 SSET_FOR_EACH (type
, &types
) {
146 if (!dp_enumerate_names(type
, &names
)) {
147 count
+= sset_count(&names
);
148 if (!dp_name
&& count
== 1) {
149 dp_name
= xasprintf("%s@%s", type
, SSET_FIRST(&names
));
152 sset_destroy(&names
);
154 sset_destroy(&types
);
157 dpctl_error(dpctl_p
, 0, "no datapaths exist");
158 } else if (count
> 1) {
159 dpctl_error(dpctl_p
, 0, "multiple datapaths, specify one");
168 parsed_dpif_open(const char *arg_
, bool create
, struct dpif
**dpifp
)
173 dp_parse_name(arg_
, &name
, &type
);
176 result
= dpif_create(name
, type
, dpifp
);
178 result
= dpif_open(name
, type
, dpifp
);
187 dpctl_add_dp(int argc
, const char *argv
[],
188 struct dpctl_params
*dpctl_p
)
193 error
= parsed_dpif_open(argv
[1], true, &dpif
);
195 dpctl_error(dpctl_p
, error
, "add_dp");
200 error
= dpctl_add_if(argc
, argv
, dpctl_p
);
206 dpctl_del_dp(int argc OVS_UNUSED
, const char *argv
[],
207 struct dpctl_params
*dpctl_p
)
212 error
= parsed_dpif_open(argv
[1], false, &dpif
);
214 dpctl_error(dpctl_p
, error
, "opening datapath");
217 error
= dpif_delete(dpif
);
219 dpctl_error(dpctl_p
, error
, "del_dp");
227 dpctl_add_if(int argc OVS_UNUSED
, const char *argv
[],
228 struct dpctl_params
*dpctl_p
)
231 int i
, error
, lasterror
= 0;
233 error
= parsed_dpif_open(argv
[1], false, &dpif
);
235 dpctl_error(dpctl_p
, error
, "opening datapath");
238 for (i
= 2; i
< argc
; i
++) {
239 const char *name
, *type
;
240 char *save_ptr
= NULL
, *argcopy
;
241 struct netdev
*netdev
= NULL
;
243 odp_port_t port_no
= ODPP_NONE
;
246 argcopy
= xstrdup(argv
[i
]);
247 name
= strtok_r(argcopy
, ",", &save_ptr
);
251 dpctl_error(dpctl_p
, 0, "%s is not a valid network device name",
258 while ((option
= strtok_r(NULL
, ",", &save_ptr
)) != NULL
) {
259 char *save_ptr_2
= NULL
;
262 key
= strtok_r(option
, "=", &save_ptr_2
);
263 value
= strtok_r(NULL
, "", &save_ptr_2
);
268 if (!strcmp(key
, "type")) {
270 } else if (!strcmp(key
, "port_no")) {
271 port_no
= u32_to_odp(atoi(value
));
272 } else if (!smap_add_once(&args
, key
, value
)) {
273 dpctl_error(dpctl_p
, 0, "duplicate \"%s\" option", key
);
277 error
= netdev_open(name
, type
, &netdev
);
279 dpctl_error(dpctl_p
, error
, "%s: failed to open network device",
281 goto next_destroy_args
;
284 error
= netdev_set_config(netdev
, &args
, NULL
);
286 goto next_destroy_args
;
289 error
= dpif_port_add(dpif
, netdev
, &port_no
);
291 dpctl_error(dpctl_p
, error
, "adding %s to %s failed", name
,
293 goto next_destroy_args
;
296 error
= if_up(netdev
);
298 dpctl_error(dpctl_p
, error
, "%s: failed bringing interface up",
303 netdev_close(netdev
);
317 dpctl_set_if(int argc
, const char *argv
[], struct dpctl_params
*dpctl_p
)
320 int i
, error
, lasterror
= 0;
322 error
= parsed_dpif_open(argv
[1], false, &dpif
);
324 dpctl_error(dpctl_p
, error
, "opening datapath");
327 for (i
= 2; i
< argc
; i
++) {
328 struct netdev
*netdev
= NULL
;
329 struct dpif_port dpif_port
;
330 char *save_ptr
= NULL
;
339 argcopy
= xstrdup(argv
[i
]);
340 name
= strtok_r(argcopy
, ",", &save_ptr
);
342 dpctl_error(dpctl_p
, 0, "%s is not a valid network device name",
347 /* Get the port's type from the datapath. */
348 error
= dpif_port_query_by_name(dpif
, name
, &dpif_port
);
350 dpctl_error(dpctl_p
, error
, "%s: failed to query port in %s", name
,
354 type
= xstrdup(dpif_port
.type
);
355 port_no
= dpif_port
.port_no
;
356 dpif_port_destroy(&dpif_port
);
358 /* Retrieve its existing configuration. */
359 error
= netdev_open(name
, type
, &netdev
);
361 dpctl_error(dpctl_p
, error
, "%s: failed to open network device",
367 error
= netdev_get_config(netdev
, &args
);
369 dpctl_error(dpctl_p
, error
, "%s: failed to fetch configuration",
371 goto next_destroy_args
;
374 /* Parse changes to configuration. */
375 while ((option
= strtok_r(NULL
, ",", &save_ptr
)) != NULL
) {
376 char *save_ptr_2
= NULL
;
379 key
= strtok_r(option
, "=", &save_ptr_2
);
380 value
= strtok_r(NULL
, "", &save_ptr_2
);
385 if (!strcmp(key
, "type")) {
386 if (strcmp(value
, type
)) {
387 dpctl_error(dpctl_p
, 0,
388 "%s: can't change type from %s to %s",
391 goto next_destroy_args
;
393 } else if (!strcmp(key
, "port_no")) {
394 if (port_no
!= u32_to_odp(atoi(value
))) {
395 dpctl_error(dpctl_p
, 0, "%s: can't change port number from"
396 " %"PRIu32
" to %d", name
, port_no
, atoi(value
));
398 goto next_destroy_args
;
400 } else if (value
[0] == '\0') {
401 smap_remove(&args
, key
);
403 smap_replace(&args
, key
, value
);
407 /* Update configuration. */
409 error
= netdev_set_config(netdev
, &args
, &err_s
);
410 if (err_s
|| error
) {
411 dpctl_error(dpctl_p
, error
, "%s",
412 err_s
? err_s
: "Error updating configuration");
416 goto next_destroy_args
;
422 netdev_close(netdev
);
435 get_port_number(struct dpif
*dpif
, const char *name
, odp_port_t
*port
,
436 struct dpctl_params
*dpctl_p
)
438 struct dpif_port dpif_port
;
440 if (!dpif_port_query_by_name(dpif
, name
, &dpif_port
)) {
441 *port
= dpif_port
.port_no
;
442 dpif_port_destroy(&dpif_port
);
445 dpctl_error(dpctl_p
, 0, "no port named %s", name
);
451 dpctl_del_if(int argc
, const char *argv
[], struct dpctl_params
*dpctl_p
)
454 int i
, error
, lasterror
= 0;
456 error
= parsed_dpif_open(argv
[1], false, &dpif
);
458 dpctl_error(dpctl_p
, error
, "opening datapath");
461 for (i
= 2; i
< argc
; i
++) {
462 const char *name
= argv
[i
];
465 if (!name
[strspn(name
, "0123456789")]) {
466 port
= u32_to_odp(atoi(name
));
467 } else if (!get_port_number(dpif
, name
, &port
, dpctl_p
)) {
472 error
= dpif_port_del(dpif
, port
);
474 dpctl_error(dpctl_p
, error
, "deleting port %s from %s failed",
484 print_stat(struct dpctl_params
*dpctl_p
, const char *leader
, uint64_t value
)
486 dpctl_print(dpctl_p
, "%s", leader
);
487 if (value
!= UINT64_MAX
) {
488 dpctl_print(dpctl_p
, "%"PRIu64
, value
);
490 dpctl_print(dpctl_p
, "?");
495 print_human_size(struct dpctl_params
*dpctl_p
, uint64_t value
)
497 if (value
== UINT64_MAX
) {
499 } else if (value
>= 1024ULL * 1024 * 1024 * 1024) {
500 dpctl_print(dpctl_p
, " (%.1f TiB)",
501 value
/ (1024.0 * 1024 * 1024 * 1024));
502 } else if (value
>= 1024ULL * 1024 * 1024) {
503 dpctl_print(dpctl_p
, " (%.1f GiB)", value
/ (1024.0 * 1024 * 1024));
504 } else if (value
>= 1024ULL * 1024) {
505 dpctl_print(dpctl_p
, " (%.1f MiB)", value
/ (1024.0 * 1024));
506 } else if (value
>= 1024) {
507 dpctl_print(dpctl_p
, " (%.1f KiB)", value
/ 1024.0);
511 /* qsort comparison function. */
513 compare_port_nos(const void *a_
, const void *b_
)
515 const odp_port_t
*ap
= a_
;
516 const odp_port_t
*bp
= b_
;
517 uint32_t a
= odp_to_u32(*ap
);
518 uint32_t b
= odp_to_u32(*bp
);
520 return a
< b
? -1 : a
> b
;
524 show_dpif(struct dpif
*dpif
, struct dpctl_params
*dpctl_p
)
526 struct dpif_port_dump dump
;
527 struct dpif_port dpif_port
;
528 struct dpif_dp_stats stats
;
529 struct netdev
*netdev
;
531 dpctl_print(dpctl_p
, "%s:\n", dpif_name(dpif
));
532 if (!dpif_get_dp_stats(dpif
, &stats
)) {
533 dpctl_print(dpctl_p
, "\tlookups: hit:%"PRIu64
" missed:%"PRIu64
534 " lost:%"PRIu64
"\n\tflows: %"PRIu64
"\n",
535 stats
.n_hit
, stats
.n_missed
, stats
.n_lost
, stats
.n_flows
);
536 if (stats
.n_masks
!= UINT32_MAX
) {
537 uint64_t n_pkts
= stats
.n_hit
+ stats
.n_missed
;
538 double avg
= n_pkts
? (double) stats
.n_mask_hit
/ n_pkts
: 0.0;
540 dpctl_print(dpctl_p
, "\tmasks: hit:%"PRIu64
" total:%"PRIu32
542 stats
.n_mask_hit
, stats
.n_masks
, avg
);
546 odp_port_t
*port_nos
= NULL
;
547 size_t allocated_port_nos
= 0, n_port_nos
= 0;
548 DPIF_PORT_FOR_EACH (&dpif_port
, &dump
, dpif
) {
549 if (n_port_nos
>= allocated_port_nos
) {
550 port_nos
= x2nrealloc(port_nos
, &allocated_port_nos
,
554 port_nos
[n_port_nos
] = dpif_port
.port_no
;
558 qsort(port_nos
, n_port_nos
, sizeof *port_nos
, compare_port_nos
);
560 for (int i
= 0; i
< n_port_nos
; i
++) {
561 if (dpif_port_query_by_number(dpif
, port_nos
[i
], &dpif_port
)) {
565 dpctl_print(dpctl_p
, "\tport %u: %s",
566 dpif_port
.port_no
, dpif_port
.name
);
568 if (strcmp(dpif_port
.type
, "system")) {
571 dpctl_print(dpctl_p
, " (%s", dpif_port
.type
);
573 error
= netdev_open(dpif_port
.name
, dpif_port
.type
, &netdev
);
578 error
= netdev_get_config(netdev
, &config
);
580 const struct smap_node
**nodes
= smap_sort(&config
);
581 for (size_t j
= 0; j
< smap_count(&config
); j
++) {
582 const struct smap_node
*node
= nodes
[j
];
583 dpctl_print(dpctl_p
, "%c %s=%s", j
? ',' : ':',
584 node
->key
, node
->value
);
588 dpctl_print(dpctl_p
, ", could not retrieve configuration "
589 "(%s)", ovs_strerror(error
));
591 smap_destroy(&config
);
593 netdev_close(netdev
);
595 dpctl_print(dpctl_p
, ": open failed (%s)",
596 ovs_strerror(error
));
598 dpctl_print(dpctl_p
, ")");
600 dpctl_print(dpctl_p
, "\n");
602 if (dpctl_p
->print_statistics
) {
603 struct netdev_stats s
;
606 error
= netdev_open(dpif_port
.name
, dpif_port
.type
, &netdev
);
608 dpctl_print(dpctl_p
, ", open failed (%s)",
609 ovs_strerror(error
));
610 dpif_port_destroy(&dpif_port
);
613 error
= netdev_get_stats(netdev
, &s
);
615 netdev_close(netdev
);
616 print_stat(dpctl_p
, "\t\tRX packets:", s
.rx_packets
);
617 print_stat(dpctl_p
, " errors:", s
.rx_errors
);
618 print_stat(dpctl_p
, " dropped:", s
.rx_dropped
);
619 print_stat(dpctl_p
, " overruns:", s
.rx_over_errors
);
620 print_stat(dpctl_p
, " frame:", s
.rx_frame_errors
);
621 dpctl_print(dpctl_p
, "\n");
623 print_stat(dpctl_p
, "\t\tTX packets:", s
.tx_packets
);
624 print_stat(dpctl_p
, " errors:", s
.tx_errors
);
625 print_stat(dpctl_p
, " dropped:", s
.tx_dropped
);
626 print_stat(dpctl_p
, " aborted:", s
.tx_aborted_errors
);
627 print_stat(dpctl_p
, " carrier:", s
.tx_carrier_errors
);
628 dpctl_print(dpctl_p
, "\n");
630 print_stat(dpctl_p
, "\t\tcollisions:", s
.collisions
);
631 dpctl_print(dpctl_p
, "\n");
633 print_stat(dpctl_p
, "\t\tRX bytes:", s
.rx_bytes
);
634 print_human_size(dpctl_p
, s
.rx_bytes
);
635 print_stat(dpctl_p
, " TX bytes:", s
.tx_bytes
);
636 print_human_size(dpctl_p
, s
.tx_bytes
);
637 dpctl_print(dpctl_p
, "\n");
639 dpctl_print(dpctl_p
, ", could not retrieve stats (%s)",
640 ovs_strerror(error
));
643 dpif_port_destroy(&dpif_port
);
649 typedef void (*dps_for_each_cb
)(struct dpif
*, struct dpctl_params
*);
652 dps_for_each(struct dpctl_params
*dpctl_p
, dps_for_each_cb cb
)
654 struct sset dpif_names
= SSET_INITIALIZER(&dpif_names
),
655 dpif_types
= SSET_INITIALIZER(&dpif_types
);
656 int error
, openerror
= 0, enumerror
= 0;
657 const char *type
, *name
;
658 bool at_least_one
= false;
660 dp_enumerate_types(&dpif_types
);
662 SSET_FOR_EACH (type
, &dpif_types
) {
663 error
= dp_enumerate_names(type
, &dpif_names
);
668 SSET_FOR_EACH (name
, &dpif_names
) {
672 error
= dpif_open(name
, type
, &dpif
);
678 dpctl_error(dpctl_p
, error
, "opening datapath %s failed",
684 sset_destroy(&dpif_names
);
685 sset_destroy(&dpif_types
);
687 /* If there has been an error while opening a datapath it should be
688 * reported. Otherwise, we want to ignore the errors generated by
689 * dp_enumerate_names() if at least one datapath has been discovered,
690 * because they're not interesting for the user. This happens, for
691 * example, if OVS is using a userspace datapath and the kernel module
696 return at_least_one
? 0 : enumerror
;
701 dpctl_show(int argc
, const char *argv
[], struct dpctl_params
*dpctl_p
)
703 int error
, lasterror
= 0;
706 for (i
= 1; i
< argc
; i
++) {
707 const char *name
= argv
[i
];
710 error
= parsed_dpif_open(name
, false, &dpif
);
712 show_dpif(dpif
, dpctl_p
);
715 dpctl_error(dpctl_p
, error
, "opening datapath %s failed",
721 lasterror
= dps_for_each(dpctl_p
, show_dpif
);
728 dump_cb(struct dpif
*dpif
, struct dpctl_params
*dpctl_p
)
730 dpctl_print(dpctl_p
, "%s\n", dpif_name(dpif
));
734 dpctl_dump_dps(int argc OVS_UNUSED
, const char *argv
[] OVS_UNUSED
,
735 struct dpctl_params
*dpctl_p
)
737 return dps_for_each(dpctl_p
, dump_cb
);
741 format_dpif_flow(struct ds
*ds
, const struct dpif_flow
*f
, struct hmap
*ports
,
742 struct dpctl_params
*dpctl_p
)
744 if (dpctl_p
->verbosity
&& f
->ufid_present
) {
745 odp_format_ufid(&f
->ufid
, ds
);
746 ds_put_cstr(ds
, ", ");
748 odp_flow_format(f
->key
, f
->key_len
, f
->mask
, f
->mask_len
, ports
, ds
,
750 ds_put_cstr(ds
, ", ");
752 dpif_flow_stats_format(&f
->stats
, ds
);
753 ds_put_cstr(ds
, ", actions:");
754 format_odp_actions(ds
, f
->actions
, f
->actions_len
);
758 dpctl_dump_flows(int argc
, const char *argv
[], struct dpctl_params
*dpctl_p
)
765 struct flow flow_filter
;
766 struct flow_wildcards wc_filter
;
768 struct dpif_port_dump port_dump
;
769 struct dpif_port dpif_port
;
770 struct hmap portno_names
;
771 struct simap names_portno
;
773 struct dpif_flow_dump_thread
*flow_dump_thread
;
774 struct dpif_flow_dump
*flow_dump
;
776 int pmd_id
= PMD_ID_NULL
;
779 if (argc
> 1 && !strncmp(argv
[argc
- 1], "filter=", 7)) {
780 filter
= xstrdup(argv
[--argc
] + 7);
782 name
= (argc
== 2) ? xstrdup(argv
[1]) : get_one_dp(dpctl_p
);
788 error
= parsed_dpif_open(name
, false, &dpif
);
791 dpctl_error(dpctl_p
, error
, "opening datapath");
796 hmap_init(&portno_names
);
797 simap_init(&names_portno
);
798 DPIF_PORT_FOR_EACH (&dpif_port
, &port_dump
, dpif
) {
799 odp_portno_names_set(&portno_names
, dpif_port
.port_no
, dpif_port
.name
);
800 simap_put(&names_portno
, dpif_port
.name
,
801 odp_to_u32(dpif_port
.port_no
));
805 char *err
= parse_ofp_exact_flow(&flow_filter
, &wc_filter
, NULL
, filter
,
808 dpctl_error(dpctl_p
, 0, "Failed to parse filter (%s)", err
);
814 /* Make sure that these values are different. PMD_ID_NULL means that the
815 * pmd is unspecified (e.g. because the datapath doesn't have different
816 * pmd threads), while NON_PMD_CORE_ID refers to every non pmd threads
817 * in the userspace datapath */
818 BUILD_ASSERT(PMD_ID_NULL
!= NON_PMD_CORE_ID
);
821 flow_dump
= dpif_flow_dump_create(dpif
, false);
822 flow_dump_thread
= dpif_flow_dump_thread_create(flow_dump
);
823 while (dpif_flow_dump_next(flow_dump_thread
, &f
, 1)) {
826 struct flow_wildcards wc
;
827 struct match match
, match_filter
;
828 struct minimatch minimatch
;
830 odp_flow_key_to_flow(f
.key
, f
.key_len
, &flow
);
831 odp_flow_key_to_mask(f
.mask
, f
.mask_len
, &wc
, &flow
);
832 match_init(&match
, &flow
, &wc
);
834 match_init(&match_filter
, &flow_filter
, &wc
);
835 match_init(&match_filter
, &match_filter
.flow
, &wc_filter
);
836 minimatch_init(&minimatch
, &match_filter
);
838 if (!minimatch_matches_flow(&minimatch
, &match
.flow
)) {
839 minimatch_destroy(&minimatch
);
842 minimatch_destroy(&minimatch
);
845 /* If 'pmd_id' is specified, overlapping flows could be dumped from
846 * different pmd threads. So, separates dumps from different pmds
847 * by printing a title line. */
848 if (pmd_id
!= f
.pmd_id
) {
849 if (f
.pmd_id
== NON_PMD_CORE_ID
) {
850 ds_put_format(&ds
, "flow-dump from non-dpdk interfaces:\n");
852 ds_put_format(&ds
, "flow-dump from pmd on cpu core: %d\n",
857 format_dpif_flow(&ds
, &f
, &portno_names
, dpctl_p
);
858 dpctl_print(dpctl_p
, "%s\n", ds_cstr(&ds
));
860 dpif_flow_dump_thread_destroy(flow_dump_thread
);
861 error
= dpif_flow_dump_destroy(flow_dump
);
864 dpctl_error(dpctl_p
, error
, "Failed to dump flows from datapath");
869 odp_portno_names_destroy(&portno_names
);
870 simap_destroy(&names_portno
);
871 hmap_destroy(&portno_names
);
879 dpctl_put_flow(int argc
, const char *argv
[], enum dpif_flow_put_flags flags
,
880 struct dpctl_params
*dpctl_p
)
882 const char *key_s
= argv
[argc
- 2];
883 const char *actions_s
= argv
[argc
- 1];
884 struct dpif_flow_stats stats
;
885 struct dpif_port dpif_port
;
886 struct dpif_port_dump port_dump
;
887 struct ofpbuf actions
;
894 struct simap port_names
;
897 dp_name
= argc
== 4 ? xstrdup(argv
[1]) : get_one_dp(dpctl_p
);
901 error
= parsed_dpif_open(dp_name
, false, &dpif
);
904 dpctl_error(dpctl_p
, error
, "opening datapath");
908 ufid_present
= false;
909 n
= odp_ufid_from_string(key_s
, &ufid
);
911 dpctl_error(dpctl_p
, -n
, "parsing flow ufid");
918 simap_init(&port_names
);
919 DPIF_PORT_FOR_EACH (&dpif_port
, &port_dump
, dpif
) {
920 simap_put(&port_names
, dpif_port
.name
, odp_to_u32(dpif_port
.port_no
));
923 ofpbuf_init(&key
, 0);
924 ofpbuf_init(&mask
, 0);
925 error
= odp_flow_from_string(key_s
, &port_names
, &key
, &mask
);
926 simap_destroy(&port_names
);
928 dpctl_error(dpctl_p
, error
, "parsing flow key");
929 goto out_freekeymask
;
932 ofpbuf_init(&actions
, 0);
933 error
= odp_actions_from_string(actions_s
, NULL
, &actions
);
935 dpctl_error(dpctl_p
, error
, "parsing actions");
936 goto out_freeactions
;
939 /* The flow will be added on all pmds currently in the datapath. */
940 error
= dpif_flow_put(dpif
, flags
,
942 mask
.size
== 0 ? NULL
: mask
.data
,
943 mask
.size
, actions
.data
,
944 actions
.size
, ufid_present
? &ufid
: NULL
,
946 dpctl_p
->print_statistics
? &stats
: NULL
);
949 dpctl_error(dpctl_p
, error
, "updating flow table");
950 goto out_freeactions
;
953 if (dpctl_p
->print_statistics
) {
957 dpif_flow_stats_format(&stats
, &s
);
958 dpctl_print(dpctl_p
, "%s\n", ds_cstr(&s
));
963 ofpbuf_uninit(&actions
);
965 ofpbuf_uninit(&mask
);
972 dpctl_add_flow(int argc
, const char *argv
[], struct dpctl_params
*dpctl_p
)
974 return dpctl_put_flow(argc
, argv
, DPIF_FP_CREATE
, dpctl_p
);
978 dpctl_mod_flow(int argc
, const char *argv
[], struct dpctl_params
*dpctl_p
)
980 enum dpif_flow_put_flags flags
;
982 flags
= DPIF_FP_MODIFY
;
983 if (dpctl_p
->may_create
) {
984 flags
|= DPIF_FP_CREATE
;
986 if (dpctl_p
->zero_statistics
) {
987 flags
|= DPIF_FP_ZERO_STATS
;
990 return dpctl_put_flow(argc
, argv
, flags
, dpctl_p
);
994 dpctl_get_flow(int argc
, const char *argv
[], struct dpctl_params
*dpctl_p
)
996 const char *key_s
= argv
[argc
- 1];
997 struct dpif_flow flow
;
998 struct dpif_port dpif_port
;
999 struct dpif_port_dump port_dump
;
1002 struct hmap portno_names
;
1005 uint64_t stub
[DPIF_FLOW_BUFSIZE
/ 8];
1009 dp_name
= argc
== 3 ? xstrdup(argv
[1]) : get_one_dp(dpctl_p
);
1013 error
= parsed_dpif_open(dp_name
, false, &dpif
);
1016 dpctl_error(dpctl_p
, error
, "opening datapath");
1020 ofpbuf_use_stub(&buf
, &stub
, sizeof stub
);
1021 hmap_init(&portno_names
);
1022 DPIF_PORT_FOR_EACH (&dpif_port
, &port_dump
, dpif
) {
1023 odp_portno_names_set(&portno_names
, dpif_port
.port_no
, dpif_port
.name
);
1026 n
= odp_ufid_from_string(key_s
, &ufid
);
1028 dpctl_error(dpctl_p
, -n
, "parsing flow ufid");
1032 /* In case of PMD will be returned flow from first PMD thread with match. */
1033 error
= dpif_flow_get(dpif
, NULL
, 0, &ufid
, PMD_ID_NULL
, &buf
, &flow
);
1035 dpctl_error(dpctl_p
, error
, "getting flow");
1040 format_dpif_flow(&ds
, &flow
, &portno_names
, dpctl_p
);
1041 dpctl_print(dpctl_p
, "%s\n", ds_cstr(&ds
));
1045 odp_portno_names_destroy(&portno_names
);
1046 hmap_destroy(&portno_names
);
1047 ofpbuf_uninit(&buf
);
1053 dpctl_del_flow(int argc
, const char *argv
[], struct dpctl_params
*dpctl_p
)
1055 const char *key_s
= argv
[argc
- 1];
1056 struct dpif_flow_stats stats
;
1057 struct dpif_port dpif_port
;
1058 struct dpif_port_dump port_dump
;
1060 struct ofpbuf mask
; /* To be ignored. */
1065 struct simap port_names
;
1068 dp_name
= argc
== 3 ? xstrdup(argv
[1]) : get_one_dp(dpctl_p
);
1072 error
= parsed_dpif_open(dp_name
, false, &dpif
);
1075 dpctl_error(dpctl_p
, error
, "opening datapath");
1079 ufid_present
= false;
1080 n
= odp_ufid_from_string(key_s
, &ufid
);
1082 dpctl_error(dpctl_p
, -n
, "parsing flow ufid");
1086 ufid_present
= true;
1089 simap_init(&port_names
);
1090 DPIF_PORT_FOR_EACH (&dpif_port
, &port_dump
, dpif
) {
1091 simap_put(&port_names
, dpif_port
.name
, odp_to_u32(dpif_port
.port_no
));
1094 ofpbuf_init(&key
, 0);
1095 ofpbuf_init(&mask
, 0);
1097 error
= odp_flow_from_string(key_s
, &port_names
, &key
, &mask
);
1099 dpctl_error(dpctl_p
, error
, "parsing flow key");
1103 /* The flow will be deleted from all pmds currently in the datapath. */
1104 error
= dpif_flow_del(dpif
, key
.data
, key
.size
,
1105 ufid_present
? &ufid
: NULL
, PMD_ID_NULL
,
1106 dpctl_p
->print_statistics
? &stats
: NULL
);
1109 dpctl_error(dpctl_p
, error
, "deleting flow");
1110 if (error
== ENOENT
&& !ufid_present
) {
1114 ds_put_format(&s
, "Perhaps you need to specify a UFID?");
1115 dpctl_print(dpctl_p
, "%s\n", ds_cstr(&s
));
1121 if (dpctl_p
->print_statistics
) {
1125 dpif_flow_stats_format(&stats
, &s
);
1126 dpctl_print(dpctl_p
, "%s\n", ds_cstr(&s
));
1131 ofpbuf_uninit(&mask
);
1132 ofpbuf_uninit(&key
);
1133 simap_destroy(&port_names
);
1139 dpctl_del_flows(int argc
, const char *argv
[], struct dpctl_params
*dpctl_p
)
1145 name
= (argc
== 2) ? xstrdup(argv
[1]) : get_one_dp(dpctl_p
);
1149 error
= parsed_dpif_open(name
, false, &dpif
);
1152 dpctl_error(dpctl_p
, error
, "opening datapath");
1156 error
= dpif_flow_flush(dpif
);
1158 dpctl_error(dpctl_p
, error
, "deleting all flows");
1165 dpctl_help(int argc OVS_UNUSED
, const char *argv
[] OVS_UNUSED
,
1166 struct dpctl_params
*dpctl_p
)
1168 if (dpctl_p
->usage
) {
1169 dpctl_p
->usage(dpctl_p
->aux
);
1176 dpctl_list_commands(int argc OVS_UNUSED
, const char *argv
[] OVS_UNUSED
,
1177 struct dpctl_params
*dpctl_p
)
1179 struct ds ds
= DS_EMPTY_INITIALIZER
;
1180 const struct dpctl_command
*commands
= get_all_dpctl_commands();
1182 ds_put_cstr(&ds
, "The available commands are:\n");
1183 for (; commands
->name
; commands
++) {
1184 const struct dpctl_command
*c
= commands
;
1186 ds_put_format(&ds
, " %s%-23s %s\n", dpctl_p
->is_appctl
? "dpctl/" : "",
1189 dpctl_puts(dpctl_p
, false, ds
.string
);
1196 dpctl_dump_conntrack(int argc
, const char *argv
[],
1197 struct dpctl_params
*dpctl_p
)
1199 struct ct_dpif_dump_state
*dump
;
1200 struct ct_dpif_entry cte
;
1201 uint16_t zone
, *pzone
= NULL
;
1206 if (argc
> 1 && ovs_scan(argv
[argc
- 1], "zone=%"SCNu16
, &zone
)) {
1210 name
= (argc
== 2) ? xstrdup(argv
[1]) : get_one_dp(dpctl_p
);
1214 error
= parsed_dpif_open(name
, false, &dpif
);
1217 dpctl_error(dpctl_p
, error
, "opening datapath");
1221 error
= ct_dpif_dump_start(dpif
, &dump
, pzone
);
1223 dpctl_error(dpctl_p
, error
, "starting conntrack dump");
1228 while (!ct_dpif_dump_next(dump
, &cte
)) {
1229 struct ds s
= DS_EMPTY_INITIALIZER
;
1231 ct_dpif_format_entry(&cte
, &s
, dpctl_p
->verbosity
,
1232 dpctl_p
->print_statistics
);
1233 ct_dpif_entry_uninit(&cte
);
1235 dpctl_print(dpctl_p
, "%s\n", ds_cstr(&s
));
1238 ct_dpif_dump_done(dump
);
1244 dpctl_flush_conntrack(int argc
, const char *argv
[],
1245 struct dpctl_params
*dpctl_p
)
1248 uint16_t zone
, *pzone
= NULL
;
1252 if (argc
> 1 && ovs_scan(argv
[argc
- 1], "zone=%"SCNu16
, &zone
)) {
1256 name
= (argc
== 2) ? xstrdup(argv
[1]) : get_one_dp(dpctl_p
);
1260 error
= parsed_dpif_open(name
, false, &dpif
);
1263 dpctl_error(dpctl_p
, error
, "opening datapath");
1267 error
= ct_dpif_flush(dpif
, pzone
);
1273 /* Undocumented commands for unit testing. */
1276 dpctl_parse_actions(int argc
, const char *argv
[], struct dpctl_params
* dpctl_p
)
1280 for (i
= 1; i
< argc
; i
++) {
1281 struct ofpbuf actions
;
1284 ofpbuf_init(&actions
, 0);
1285 error
= odp_actions_from_string(argv
[i
], NULL
, &actions
);
1288 ofpbuf_uninit(&actions
);
1289 dpctl_error(dpctl_p
, error
, "odp_actions_from_string");
1294 format_odp_actions(&s
, actions
.data
, actions
.size
);
1295 dpctl_print(dpctl_p
, "%s\n", ds_cstr(&s
));
1298 ofpbuf_uninit(&actions
);
1304 struct actions_for_flow
{
1305 struct hmap_node hmap_node
;
1307 struct ofpbuf actions
;
1310 static struct actions_for_flow
*
1311 get_actions_for_flow(struct hmap
*actions_per_flow
, const struct flow
*flow
)
1313 uint32_t hash
= flow_hash(flow
, 0);
1314 struct actions_for_flow
*af
;
1316 HMAP_FOR_EACH_WITH_HASH (af
, hmap_node
, hash
, actions_per_flow
) {
1317 if (flow_equal(&af
->flow
, flow
)) {
1322 af
= xmalloc(sizeof *af
);
1324 ofpbuf_init(&af
->actions
, 0);
1325 hmap_insert(actions_per_flow
, &af
->hmap_node
, hash
);
1330 compare_actions_for_flow(const void *a_
, const void *b_
)
1332 struct actions_for_flow
*const *a
= a_
;
1333 struct actions_for_flow
*const *b
= b_
;
1335 return flow_compare_3way(&(*a
)->flow
, &(*b
)->flow
);
1339 compare_output_actions(const void *a_
, const void *b_
)
1341 const struct nlattr
*a
= a_
;
1342 const struct nlattr
*b
= b_
;
1343 uint32_t a_port
= nl_attr_get_u32(a
);
1344 uint32_t b_port
= nl_attr_get_u32(b
);
1346 return a_port
< b_port
? -1 : a_port
> b_port
;
1350 sort_output_actions__(struct nlattr
*first
, struct nlattr
*end
)
1352 size_t bytes
= (uint8_t *) end
- (uint8_t *) first
;
1353 size_t n
= bytes
/ NL_A_U32_SIZE
;
1355 ovs_assert(bytes
% NL_A_U32_SIZE
== 0);
1356 qsort(first
, n
, NL_A_U32_SIZE
, compare_output_actions
);
1360 sort_output_actions(struct nlattr
*actions
, size_t length
)
1362 struct nlattr
*first_output
= NULL
;
1366 NL_ATTR_FOR_EACH (a
, left
, actions
, length
) {
1367 if (nl_attr_type(a
) == OVS_ACTION_ATTR_OUTPUT
) {
1368 if (!first_output
) {
1373 sort_output_actions__(first_output
, a
);
1374 first_output
= NULL
;
1379 uint8_t *end
= (uint8_t *) actions
+ length
;
1380 sort_output_actions__(first_output
,
1381 ALIGNED_CAST(struct nlattr
*, end
));
1385 /* usage: "ovs-dpctl normalize-actions FLOW ACTIONS" where FLOW and ACTIONS
1386 * have the syntax used by "ovs-dpctl dump-flows".
1388 * This command prints ACTIONS in a format that shows what happens for each
1389 * VLAN, independent of the order of the ACTIONS. For example, there is more
1390 * than one way to output a packet on VLANs 9 and 11, but this command will
1391 * print the same output for any form.
1393 * The idea here generalizes beyond VLANs (e.g. to setting other fields) but
1394 * so far the implementation only covers VLANs. */
1396 dpctl_normalize_actions(int argc
, const char *argv
[],
1397 struct dpctl_params
*dpctl_p
)
1399 struct simap port_names
;
1400 struct ofpbuf keybuf
;
1402 struct ofpbuf odp_actions
;
1403 struct hmap actions_per_flow
;
1404 struct actions_for_flow
**afs
;
1405 struct actions_for_flow
*af
;
1415 simap_init(&port_names
);
1416 for (i
= 3; i
< argc
; i
++) {
1420 if (ovs_scan(argv
[i
], "%15[^=]=%d", name
, &number
)) {
1421 uintptr_t n
= number
;
1422 simap_put(&port_names
, name
, n
);
1424 dpctl_error(dpctl_p
, 0, "%s: expected NAME=NUMBER", argv
[i
]);
1430 /* Parse flow key. */
1431 ofpbuf_init(&keybuf
, 0);
1432 error
= odp_flow_from_string(argv
[1], &port_names
, &keybuf
, NULL
);
1434 dpctl_error(dpctl_p
, error
, "odp_flow_key_from_string");
1435 goto out_freekeybuf
;
1439 odp_flow_format(keybuf
.data
, keybuf
.size
, NULL
, 0, NULL
,
1440 &s
, dpctl_p
->verbosity
);
1441 dpctl_print(dpctl_p
, "input flow: %s\n", ds_cstr(&s
));
1443 error
= odp_flow_key_to_flow(keybuf
.data
, keybuf
.size
, &flow
);
1445 dpctl_error(dpctl_p
, error
, "odp_flow_key_to_flow");
1446 goto out_freekeybuf
;
1449 /* Parse actions. */
1450 ofpbuf_init(&odp_actions
, 0);
1451 error
= odp_actions_from_string(argv
[2], &port_names
, &odp_actions
);
1453 dpctl_error(dpctl_p
, error
, "odp_actions_from_string");
1454 goto out_freeactions
;
1457 if (dpctl_p
->verbosity
) {
1459 format_odp_actions(&s
, odp_actions
.data
, odp_actions
.size
);
1460 dpctl_print(dpctl_p
, "input actions: %s\n", ds_cstr(&s
));
1463 hmap_init(&actions_per_flow
);
1464 NL_ATTR_FOR_EACH (a
, left
, odp_actions
.data
, odp_actions
.size
) {
1465 const struct ovs_action_push_vlan
*push
;
1466 switch(nl_attr_type(a
)) {
1467 case OVS_ACTION_ATTR_POP_VLAN
:
1468 flow_pop_vlan(&flow
, NULL
);
1471 case OVS_ACTION_ATTR_PUSH_VLAN
:
1472 flow_push_vlan_uninit(&flow
, NULL
);
1473 push
= nl_attr_get_unspec(a
, sizeof *push
);
1474 flow
.vlans
[0].tpid
= push
->vlan_tpid
;
1475 flow
.vlans
[0].tci
= push
->vlan_tci
;
1479 af
= get_actions_for_flow(&actions_per_flow
, &flow
);
1480 nl_msg_put_unspec(&af
->actions
, nl_attr_type(a
),
1481 nl_attr_get(a
), nl_attr_get_size(a
));
1484 n_afs
= hmap_count(&actions_per_flow
);
1485 afs
= xmalloc(n_afs
* sizeof *afs
);
1487 HMAP_FOR_EACH (af
, hmap_node
, &actions_per_flow
) {
1491 ovs_assert(i
== n_afs
);
1492 hmap_destroy(&actions_per_flow
);
1494 qsort(afs
, n_afs
, sizeof *afs
, compare_actions_for_flow
);
1496 for (i
= 0; i
< n_afs
; i
++) {
1497 struct actions_for_flow
*af
= afs
[i
];
1499 sort_output_actions(af
->actions
.data
, af
->actions
.size
);
1501 for (encaps
= 0; encaps
< FLOW_MAX_VLAN_HEADERS
; encaps
++) {
1502 union flow_vlan_hdr
*vlan
= &af
->flow
.vlans
[encaps
];
1503 if (vlan
->tci
!= htons(0)) {
1504 dpctl_print(dpctl_p
, "vlan(");
1505 if (vlan
->tpid
!= htons(ETH_TYPE_VLAN
)) {
1506 dpctl_print(dpctl_p
, "tpid=0x%04"PRIx16
",", vlan
->tpid
);
1508 dpctl_print(dpctl_p
, "vid=%"PRIu16
",pcp=%d): ",
1509 vlan_tci_to_vid(vlan
->tci
),
1510 vlan_tci_to_pcp(vlan
->tci
));
1513 dpctl_print(dpctl_p
, "no vlan: ");
1519 if (eth_type_mpls(af
->flow
.dl_type
)) {
1520 dpctl_print(dpctl_p
, "mpls(label=%"PRIu32
",tc=%d,ttl=%d): ",
1521 mpls_lse_to_label(af
->flow
.mpls_lse
[0]),
1522 mpls_lse_to_tc(af
->flow
.mpls_lse
[0]),
1523 mpls_lse_to_ttl(af
->flow
.mpls_lse
[0]));
1525 dpctl_print(dpctl_p
, "no mpls: ");
1529 format_odp_actions(&s
, af
->actions
.data
, af
->actions
.size
);
1530 dpctl_puts(dpctl_p
, false, ds_cstr(&s
));
1532 ofpbuf_uninit(&af
->actions
);
1539 ofpbuf_uninit(&odp_actions
);
1541 ofpbuf_uninit(&keybuf
);
1543 simap_destroy(&port_names
);
1549 static const struct dpctl_command all_commands
[] = {
1550 { "add-dp", "dp [iface...]", 1, INT_MAX
, dpctl_add_dp
, DP_RW
},
1551 { "del-dp", "dp", 1, 1, dpctl_del_dp
, DP_RW
},
1552 { "add-if", "dp iface...", 2, INT_MAX
, dpctl_add_if
, DP_RW
},
1553 { "del-if", "dp iface...", 2, INT_MAX
, dpctl_del_if
, DP_RW
},
1554 { "set-if", "dp iface...", 2, INT_MAX
, dpctl_set_if
, DP_RW
},
1555 { "dump-dps", "", 0, 0, dpctl_dump_dps
, DP_RO
},
1556 { "show", "[dp...]", 0, INT_MAX
, dpctl_show
, DP_RO
},
1557 { "dump-flows", "[dp]", 0, 2, dpctl_dump_flows
, DP_RO
},
1558 { "add-flow", "[dp] flow actions", 2, 3, dpctl_add_flow
, DP_RW
},
1559 { "mod-flow", "[dp] flow actions", 2, 3, dpctl_mod_flow
, DP_RW
},
1560 { "get-flow", "[dp] ufid", 1, 2, dpctl_get_flow
, DP_RO
},
1561 { "del-flow", "[dp] flow", 1, 2, dpctl_del_flow
, DP_RW
},
1562 { "del-flows", "[dp]", 0, 1, dpctl_del_flows
, DP_RW
},
1563 { "dump-conntrack", "[dp] [zone=N]", 0, 2, dpctl_dump_conntrack
, DP_RO
},
1564 { "flush-conntrack", "[dp] [zone=N]", 0, 2, dpctl_flush_conntrack
, DP_RW
},
1565 { "help", "", 0, INT_MAX
, dpctl_help
, DP_RO
},
1566 { "list-commands", "", 0, INT_MAX
, dpctl_list_commands
, DP_RO
},
1568 /* Undocumented commands for testing. */
1569 { "parse-actions", "actions", 1, INT_MAX
, dpctl_parse_actions
, DP_RO
},
1570 { "normalize-actions", "actions", 2, INT_MAX
, dpctl_normalize_actions
, DP_RO
},
1572 { NULL
, NULL
, 0, 0, NULL
, DP_RO
},
1575 static const struct dpctl_command
*get_all_dpctl_commands(void)
1577 return all_commands
;
1580 /* Runs the command designated by argv[0] within the command table specified by
1581 * 'commands', which must be terminated by a command whose 'name' member is a
1584 dpctl_run_command(int argc
, const char *argv
[], struct dpctl_params
*dpctl_p
)
1586 const struct dpctl_command
*p
;
1589 dpctl_error(dpctl_p
, 0, "missing command name; use --help for help");
1593 for (p
= all_commands
; p
->name
!= NULL
; p
++) {
1594 if (!strcmp(p
->name
, argv
[0])) {
1595 int n_arg
= argc
- 1;
1596 if (n_arg
< p
->min_args
) {
1597 dpctl_error(dpctl_p
, 0,
1598 "'%s' command requires at least %d arguments",
1599 p
->name
, p
->min_args
);
1601 } else if (n_arg
> p
->max_args
) {
1602 dpctl_error(dpctl_p
, 0,
1603 "'%s' command takes at most %d arguments",
1604 p
->name
, p
->max_args
);
1607 if (p
->mode
== DP_RW
&& dpctl_p
->read_only
) {
1608 dpctl_error(dpctl_p
, 0,
1609 "'%s' command does not work in read only mode",
1613 return p
->handler(argc
, argv
, dpctl_p
);
1618 dpctl_error(dpctl_p
, 0, "unknown command '%s'; use --help for help",
1624 dpctl_unixctl_print(void *userdata
, bool error OVS_UNUSED
, const char *msg
)
1626 struct ds
*ds
= userdata
;
1627 ds_put_cstr(ds
, msg
);
1631 dpctl_unixctl_handler(struct unixctl_conn
*conn
, int argc
, const char *argv
[],
1634 struct ds ds
= DS_EMPTY_INITIALIZER
;
1637 struct dpctl_params dpctl_p
= {
1639 .output
= dpctl_unixctl_print
,
1643 /* Parse options (like getopt). Unfortunately it does
1644 * not seem a good idea to call getopt_long() here, since it uses global
1646 while (argc
> 1 && !error
) {
1647 const char *arg
= argv
[1];
1648 if (!strncmp(arg
, "--", 2)) {
1650 if (!strcmp(arg
, "--statistics")) {
1651 dpctl_p
.print_statistics
= true;
1652 } else if (!strcmp(arg
, "--clear")) {
1653 dpctl_p
.zero_statistics
= true;
1654 } else if (!strcmp(arg
, "--may-create")) {
1655 dpctl_p
.may_create
= true;
1656 } else if (!strcmp(arg
, "--more")) {
1657 dpctl_p
.verbosity
++;
1659 ds_put_format(&ds
, "Unrecognized option %s", argv
[1]);
1662 } else if (arg
[0] == '-' && arg
[1] != '\0') {
1663 /* Short option[s] */
1664 const char *opt
= &arg
[1];
1666 while (*opt
&& !error
) {
1669 dpctl_p
.verbosity
++;
1672 dpctl_p
.print_statistics
= true;
1675 ds_put_format(&ds
, "Unrecognized option -%c", *opt
);
1682 /* Doesn't start with -, not an option */
1694 dpctl_command_handler
*handler
= (dpctl_command_handler
*) aux
;
1695 error
= handler(argc
, argv
, &dpctl_p
) != 0;
1699 unixctl_command_reply_error(conn
, ds_cstr(&ds
));
1701 unixctl_command_reply(conn
, ds_cstr(&ds
));
1708 dpctl_unixctl_register(void)
1710 const struct dpctl_command
*p
;
1712 for (p
= all_commands
; p
->name
!= NULL
; p
++) {
1713 if (strcmp(p
->name
, "help")) {
1714 char *cmd_name
= xasprintf("dpctl/%s", p
->name
);
1715 unixctl_command_register(cmd_name
,
1719 dpctl_unixctl_handler
,