• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3  * Copyright (c) 2008-2013 Thomas Graf <tgraf@suug.ch>
4  */
5 
6 #include <netlink-private/netlink.h>
7 #include <netlink-private/tc.h>
8 #include <netlink/netlink.h>
9 #include <netlink/route/cls/ematch.h>
10 
container_parse(struct rtnl_ematch * e,void * data,size_t len)11 static int container_parse(struct rtnl_ematch *e, void *data, size_t len __attribute__((unused)))
12 {
13 	/*
14 	The kernel may provide more than 4 bytes of data in the future and we want
15 	older libnl versions to be ok with that. We want interfaces to be growable
16 	so we only ever enforce a minimum data length and copy as much as we are
17 	aware of. Thomas Graf.
18 	*/
19 	memcpy(e->e_data, data, sizeof(uint32_t));
20 
21 	return 0;
22 }
23 
container_fill(struct rtnl_ematch * e,struct nl_msg * msg)24 static int container_fill(struct rtnl_ematch *e, struct nl_msg *msg)
25 {
26 	return nlmsg_append(msg, e->e_data, sizeof(uint32_t), 0);
27 }
28 
29 static struct rtnl_ematch_ops container_ops = {
30 	.eo_kind	= TCF_EM_CONTAINER,
31 	.eo_name	= "container",
32 	.eo_minlen	= sizeof(uint32_t),
33 	.eo_datalen	= sizeof(uint32_t),
34 	.eo_parse	= container_parse,
35 	.eo_fill	= container_fill,
36 };
37 
container_init(void)38 static void __init container_init(void)
39 {
40 	rtnl_ematch_register(&container_ops);
41 }
42