mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-23 03:29:43 +00:00
netfilter: Use class properties
Instance properties make introspection hard and are not shown by "-object ...,help". Convert them to class properties. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20201111183823.283752-12-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
6d11ea6d8e
commit
f0e34a06f6
10
net/dump.c
10
net/dump.c
@ -224,11 +224,6 @@ static void filter_dump_instance_init(Object *obj)
|
||||
NetFilterDumpState *nfds = FILTER_DUMP(obj);
|
||||
|
||||
nfds->maxlen = 65536;
|
||||
|
||||
object_property_add(obj, "maxlen", "uint32", filter_dump_get_maxlen,
|
||||
filter_dump_set_maxlen, NULL, NULL);
|
||||
object_property_add_str(obj, "file", file_dump_get_filename,
|
||||
file_dump_set_filename);
|
||||
}
|
||||
|
||||
static void filter_dump_instance_finalize(Object *obj)
|
||||
@ -242,6 +237,11 @@ static void filter_dump_class_init(ObjectClass *oc, void *data)
|
||||
{
|
||||
NetFilterClass *nfc = NETFILTER_CLASS(oc);
|
||||
|
||||
object_class_property_add(oc, "maxlen", "uint32", filter_dump_get_maxlen,
|
||||
filter_dump_set_maxlen, NULL, NULL);
|
||||
object_class_property_add_str(oc, "file", file_dump_get_filename,
|
||||
file_dump_set_filename);
|
||||
|
||||
nfc->setup = filter_dump_setup;
|
||||
nfc->cleanup = filter_dump_cleanup;
|
||||
nfc->receive_iov = filter_dump_receive_iov;
|
||||
|
@ -176,24 +176,20 @@ static void filter_buffer_class_init(ObjectClass *oc, void *data)
|
||||
{
|
||||
NetFilterClass *nfc = NETFILTER_CLASS(oc);
|
||||
|
||||
object_class_property_add(oc, "interval", "uint32",
|
||||
filter_buffer_get_interval,
|
||||
filter_buffer_set_interval, NULL, NULL);
|
||||
|
||||
nfc->setup = filter_buffer_setup;
|
||||
nfc->cleanup = filter_buffer_cleanup;
|
||||
nfc->receive_iov = filter_buffer_receive_iov;
|
||||
nfc->status_changed = filter_buffer_status_changed;
|
||||
}
|
||||
|
||||
static void filter_buffer_init(Object *obj)
|
||||
{
|
||||
object_property_add(obj, "interval", "uint32",
|
||||
filter_buffer_get_interval,
|
||||
filter_buffer_set_interval, NULL, NULL);
|
||||
}
|
||||
|
||||
static const TypeInfo filter_buffer_info = {
|
||||
.name = TYPE_FILTER_BUFFER,
|
||||
.parent = TYPE_NETFILTER,
|
||||
.class_init = filter_buffer_class_init,
|
||||
.instance_init = filter_buffer_init,
|
||||
.instance_size = sizeof(FilterBufferState),
|
||||
};
|
||||
|
||||
|
@ -374,6 +374,12 @@ static void filter_mirror_class_init(ObjectClass *oc, void *data)
|
||||
{
|
||||
NetFilterClass *nfc = NETFILTER_CLASS(oc);
|
||||
|
||||
object_class_property_add_str(oc, "outdev", filter_mirror_get_outdev,
|
||||
filter_mirror_set_outdev);
|
||||
object_class_property_add_bool(oc, "vnet_hdr_support",
|
||||
filter_mirror_get_vnet_hdr,
|
||||
filter_mirror_set_vnet_hdr);
|
||||
|
||||
nfc->setup = filter_mirror_setup;
|
||||
nfc->cleanup = filter_mirror_cleanup;
|
||||
nfc->receive_iov = filter_mirror_receive_iov;
|
||||
@ -383,6 +389,14 @@ static void filter_redirector_class_init(ObjectClass *oc, void *data)
|
||||
{
|
||||
NetFilterClass *nfc = NETFILTER_CLASS(oc);
|
||||
|
||||
object_class_property_add_str(oc, "indev", filter_redirector_get_indev,
|
||||
filter_redirector_set_indev);
|
||||
object_class_property_add_str(oc, "outdev", filter_redirector_get_outdev,
|
||||
filter_redirector_set_outdev);
|
||||
object_class_property_add_bool(oc, "vnet_hdr_support",
|
||||
filter_redirector_get_vnet_hdr,
|
||||
filter_redirector_set_vnet_hdr);
|
||||
|
||||
nfc->setup = filter_redirector_setup;
|
||||
nfc->cleanup = filter_redirector_cleanup;
|
||||
nfc->receive_iov = filter_redirector_receive_iov;
|
||||
@ -392,28 +406,14 @@ static void filter_mirror_init(Object *obj)
|
||||
{
|
||||
MirrorState *s = FILTER_MIRROR(obj);
|
||||
|
||||
object_property_add_str(obj, "outdev", filter_mirror_get_outdev,
|
||||
filter_mirror_set_outdev);
|
||||
|
||||
s->vnet_hdr = false;
|
||||
object_property_add_bool(obj, "vnet_hdr_support",
|
||||
filter_mirror_get_vnet_hdr,
|
||||
filter_mirror_set_vnet_hdr);
|
||||
}
|
||||
|
||||
static void filter_redirector_init(Object *obj)
|
||||
{
|
||||
MirrorState *s = FILTER_REDIRECTOR(obj);
|
||||
|
||||
object_property_add_str(obj, "indev", filter_redirector_get_indev,
|
||||
filter_redirector_set_indev);
|
||||
object_property_add_str(obj, "outdev", filter_redirector_get_outdev,
|
||||
filter_redirector_set_outdev);
|
||||
|
||||
s->vnet_hdr = false;
|
||||
object_property_add_bool(obj, "vnet_hdr_support",
|
||||
filter_redirector_get_vnet_hdr,
|
||||
filter_redirector_set_vnet_hdr);
|
||||
}
|
||||
|
||||
static void filter_mirror_fini(Object *obj)
|
||||
|
@ -418,15 +418,16 @@ static void filter_rewriter_init(Object *obj)
|
||||
|
||||
s->vnet_hdr = false;
|
||||
s->failover_mode = FAILOVER_MODE_OFF;
|
||||
object_property_add_bool(obj, "vnet_hdr_support",
|
||||
filter_rewriter_get_vnet_hdr,
|
||||
filter_rewriter_set_vnet_hdr);
|
||||
}
|
||||
|
||||
static void colo_rewriter_class_init(ObjectClass *oc, void *data)
|
||||
{
|
||||
NetFilterClass *nfc = NETFILTER_CLASS(oc);
|
||||
|
||||
object_class_property_add_bool(oc, "vnet_hdr_support",
|
||||
filter_rewriter_get_vnet_hdr,
|
||||
filter_rewriter_set_vnet_hdr);
|
||||
|
||||
nfc->setup = colo_rewriter_setup;
|
||||
nfc->cleanup = colo_rewriter_cleanup;
|
||||
nfc->receive_iov = colo_rewriter_receive_iov;
|
||||
|
24
net/filter.c
24
net/filter.c
@ -212,18 +212,6 @@ static void netfilter_init(Object *obj)
|
||||
nf->on = true;
|
||||
nf->insert_before_flag = false;
|
||||
nf->position = g_strdup("tail");
|
||||
|
||||
object_property_add_str(obj, "netdev",
|
||||
netfilter_get_netdev_id, netfilter_set_netdev_id);
|
||||
object_property_add_enum(obj, "queue", "NetFilterDirection",
|
||||
&NetFilterDirection_lookup,
|
||||
netfilter_get_direction, netfilter_set_direction);
|
||||
object_property_add_str(obj, "status",
|
||||
netfilter_get_status, netfilter_set_status);
|
||||
object_property_add_str(obj, "position",
|
||||
netfilter_get_position, netfilter_set_position);
|
||||
object_property_add_str(obj, "insert",
|
||||
netfilter_get_insert, netfilter_set_insert);
|
||||
}
|
||||
|
||||
static void netfilter_complete(UserCreatable *uc, Error **errp)
|
||||
@ -350,6 +338,18 @@ static void netfilter_class_init(ObjectClass *oc, void *data)
|
||||
UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
|
||||
NetFilterClass *nfc = NETFILTER_CLASS(oc);
|
||||
|
||||
object_class_property_add_str(oc, "netdev",
|
||||
netfilter_get_netdev_id, netfilter_set_netdev_id);
|
||||
object_class_property_add_enum(oc, "queue", "NetFilterDirection",
|
||||
&NetFilterDirection_lookup,
|
||||
netfilter_get_direction, netfilter_set_direction);
|
||||
object_class_property_add_str(oc, "status",
|
||||
netfilter_get_status, netfilter_set_status);
|
||||
object_class_property_add_str(oc, "position",
|
||||
netfilter_get_position, netfilter_set_position);
|
||||
object_class_property_add_str(oc, "insert",
|
||||
netfilter_get_insert, netfilter_set_insert);
|
||||
|
||||
ucc->complete = netfilter_complete;
|
||||
nfc->handle_event = default_handle_event;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user