mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-07 07:50:17 +01:00
platform: add methods to delete tc qdiscs and tfilters
Introduce two platform methods to delete tc qdiscs and filters by ifindex and parent.
This commit is contained in:
parent
8003ca68f7
commit
d9b2e9d7ea
3 changed files with 106 additions and 4 deletions
|
|
@ -8850,7 +8850,79 @@ qdisc_add(NMPlatform *platform, NMPNlmFlags flags, const NMPlatformQdisc *qdisc)
|
|||
return -NME_UNSPEC;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int
|
||||
tc_delete(NMPlatform *platform, int nlmsgtype, int ifindex, guint32 parent, gboolean log_error)
|
||||
{
|
||||
WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN;
|
||||
gs_free char * errmsg = NULL;
|
||||
int nle;
|
||||
char s_buf[256];
|
||||
const char * log_tag;
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
const struct tcmsg tcm = {
|
||||
.tcm_ifindex = ifindex,
|
||||
.tcm_parent = parent,
|
||||
};
|
||||
|
||||
switch (nlmsgtype) {
|
||||
case RTM_DELQDISC:
|
||||
log_tag = "do-delete-qdisc";
|
||||
break;
|
||||
case RTM_DELTFILTER:
|
||||
log_tag = "do-delete-tfilter";
|
||||
break;
|
||||
default:
|
||||
nm_assert_not_reached();
|
||||
log_tag = "do-delete-tc";
|
||||
}
|
||||
|
||||
msg = nlmsg_alloc_simple(nlmsgtype, NMP_NLM_FLAG_F_ECHO);
|
||||
|
||||
if (nlmsg_append_struct(msg, &tcm) < 0)
|
||||
goto nla_put_failure;
|
||||
|
||||
event_handler_read_netlink(platform, FALSE);
|
||||
|
||||
nle = _nl_send_nlmsg(platform,
|
||||
msg,
|
||||
&seq_result,
|
||||
&errmsg,
|
||||
DELAYED_ACTION_RESPONSE_TYPE_VOID,
|
||||
NULL);
|
||||
if (nle < 0) {
|
||||
_NMLOG(log_error ? LOGL_ERR : LOGL_DEBUG,
|
||||
"%s: failed sending netlink request \"%s\" (%d)",
|
||||
log_tag,
|
||||
nm_strerror(nle),
|
||||
-nle);
|
||||
return -NME_PL_NETLINK;
|
||||
}
|
||||
|
||||
delayed_action_handle_all(platform, FALSE);
|
||||
|
||||
nm_assert(seq_result);
|
||||
|
||||
_NMLOG((seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK || !log_error) ? LOGL_DEBUG
|
||||
: LOGL_WARN,
|
||||
"%s: %s",
|
||||
log_tag,
|
||||
wait_for_nl_response_to_string(seq_result, errmsg, s_buf, sizeof(s_buf)));
|
||||
|
||||
if (seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK)
|
||||
return 0;
|
||||
if (seq_result < 0)
|
||||
return seq_result;
|
||||
return -NME_UNSPEC;
|
||||
|
||||
nla_put_failure:
|
||||
g_return_val_if_reached(-NME_UNSPEC);
|
||||
}
|
||||
|
||||
static int
|
||||
qdisc_delete(NMPlatform *platform, int ifindex, guint32 parent, gboolean log_error)
|
||||
{
|
||||
return tc_delete(platform, RTM_DELQDISC, ifindex, parent, log_error);
|
||||
}
|
||||
|
||||
static int
|
||||
tfilter_add(NMPlatform *platform, NMPNlmFlags flags, const NMPlatformTfilter *tfilter)
|
||||
|
|
@ -8893,6 +8965,12 @@ tfilter_add(NMPlatform *platform, NMPNlmFlags flags, const NMPlatformTfilter *tf
|
|||
return -NME_UNSPEC;
|
||||
}
|
||||
|
||||
static int
|
||||
tfilter_delete(NMPlatform *platform, int ifindex, guint32 parent, gboolean log_error)
|
||||
{
|
||||
return tc_delete(platform, RTM_DELTFILTER, ifindex, parent, log_error);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
|
|
@ -9687,8 +9765,10 @@ nm_linux_platform_class_init(NMLinuxPlatformClass *klass)
|
|||
|
||||
platform_class->routing_rule_add = routing_rule_add;
|
||||
|
||||
platform_class->qdisc_add = qdisc_add;
|
||||
platform_class->tfilter_add = tfilter_add;
|
||||
platform_class->qdisc_add = qdisc_add;
|
||||
platform_class->qdisc_delete = qdisc_delete;
|
||||
platform_class->tfilter_add = tfilter_add;
|
||||
platform_class->tfilter_delete = tfilter_delete;
|
||||
|
||||
platform_class->process_events = process_events;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5295,6 +5295,15 @@ nm_platform_qdisc_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformQdisc
|
|||
return klass->qdisc_add(self, flags, qdisc);
|
||||
}
|
||||
|
||||
int
|
||||
nm_platform_qdisc_delete(NMPlatform *self, int ifindex, guint32 parent, gboolean log_error)
|
||||
{
|
||||
_CHECK_SELF(self, klass, -NME_BUG);
|
||||
|
||||
_LOG3D("deleting a qdisc: parent 0x%08x", parent);
|
||||
return klass->qdisc_delete(self, ifindex, parent, log_error);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_platform_qdisc_sync:
|
||||
* @self: the #NMPlatform instance
|
||||
|
|
@ -5398,6 +5407,15 @@ nm_platform_tfilter_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformTfi
|
|||
return klass->tfilter_add(self, flags, tfilter);
|
||||
}
|
||||
|
||||
int
|
||||
nm_platform_tfilter_delete(NMPlatform *self, int ifindex, guint32 parent, gboolean log_error)
|
||||
{
|
||||
_CHECK_SELF(self, klass, -NME_BUG);
|
||||
|
||||
_LOG3D("deleting a tfilter: parent 0x%08x", parent);
|
||||
return klass->tfilter_delete(self, ifindex, parent, log_error);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_platform_qdisc_sync:
|
||||
* @self: the #NMPlatform instance
|
||||
|
|
|
|||
|
|
@ -1266,8 +1266,10 @@ typedef struct {
|
|||
const NMPlatformRoutingRule *routing_rule);
|
||||
|
||||
int (*qdisc_add)(NMPlatform *self, NMPNlmFlags flags, const NMPlatformQdisc *qdisc);
|
||||
int (*qdisc_delete)(NMPlatform *self, int ifindex, guint32 parent, gboolean log_error);
|
||||
|
||||
int (*tfilter_add)(NMPlatform *self, NMPNlmFlags flags, const NMPlatformTfilter *tfilter);
|
||||
int (*tfilter_delete)(NMPlatform *self, int ifindex, guint32 parent, gboolean log_error);
|
||||
} NMPlatformClass;
|
||||
|
||||
/* NMPlatform signals
|
||||
|
|
@ -2219,10 +2221,12 @@ int nm_platform_routing_rule_add(NMPlatform * self,
|
|||
NMPNlmFlags flags,
|
||||
const NMPlatformRoutingRule *routing_rule);
|
||||
|
||||
int nm_platform_qdisc_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformQdisc *qdisc);
|
||||
int nm_platform_qdisc_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformQdisc *qdisc);
|
||||
int nm_platform_qdisc_delete(NMPlatform *self, int ifindex, guint32 parent, gboolean log_error);
|
||||
gboolean nm_platform_qdisc_sync(NMPlatform *self, int ifindex, GPtrArray *known_qdiscs);
|
||||
|
||||
int nm_platform_tfilter_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformTfilter *tfilter);
|
||||
int nm_platform_tfilter_delete(NMPlatform *self, int ifindex, guint32 parent, gboolean log_error);
|
||||
gboolean nm_platform_tfilter_sync(NMPlatform *self, int ifindex, GPtrArray *known_tfilters);
|
||||
|
||||
const char *nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue