-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools: ynl: generate code for ovs families
Add ovs_flow, ovs_vport and ovs_datapath to the families supported in C. ovs-flow has some circular nesting which is fun to deal with, but the necessary support has been added already in the previous release cycle. Add a sample that proves that dealing with fixed headers does actually work correctly. Reviewed-by: Jiri Pirko <jiri@nvidia.com> Link: https://lore.kernel.org/r/20240202004926.447803-3-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
- Loading branch information
Jakub Kicinski
committed
Feb 3, 2024
1 parent
8f109e9
commit 7c59c9c
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
ethtool | ||
devlink | ||
netdev | ||
ovs | ||
page-pool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#include <ynl.h> | ||
|
||
#include "ovs_datapath-user.h" | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
struct ynl_sock *ys; | ||
int err; | ||
|
||
ys = ynl_sock_create(&ynl_ovs_datapath_family, NULL); | ||
if (!ys) | ||
return 1; | ||
|
||
if (argc > 1) { | ||
struct ovs_datapath_new_req *req; | ||
|
||
req = ovs_datapath_new_req_alloc(); | ||
if (!req) | ||
goto err_close; | ||
|
||
ovs_datapath_new_req_set_upcall_pid(req, 1); | ||
ovs_datapath_new_req_set_name(req, argv[1]); | ||
|
||
err = ovs_datapath_new(ys, req); | ||
ovs_datapath_new_req_free(req); | ||
if (err) | ||
goto err_close; | ||
} else { | ||
struct ovs_datapath_get_req_dump *req; | ||
struct ovs_datapath_get_list *dps; | ||
|
||
printf("Dump:\n"); | ||
req = ovs_datapath_get_req_dump_alloc(); | ||
|
||
dps = ovs_datapath_get_dump(ys, req); | ||
ovs_datapath_get_req_dump_free(req); | ||
if (!dps) | ||
goto err_close; | ||
|
||
ynl_dump_foreach(dps, dp) { | ||
printf(" %s(%d): pid:%u cache:%u\n", | ||
dp->name, dp->_hdr.dp_ifindex, | ||
dp->upcall_pid, dp->masks_cache_size); | ||
} | ||
ovs_datapath_get_list_free(dps); | ||
} | ||
|
||
ynl_sock_destroy(ys); | ||
|
||
return 0; | ||
|
||
err_close: | ||
fprintf(stderr, "YNL (%d): %s\n", ys->err.code, ys->err.msg); | ||
ynl_sock_destroy(ys); | ||
return 2; | ||
} |