blob: 4b1b2b9f482896821d054da6b44043f5f5de90d9 [file] [log] [blame]
Maciej Żenczykowskib70da762019-01-28 15:20:48 -08001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
Maciej Żenczykowski776200e2020-02-05 02:05:16 -080017#pragma once
Maciej Żenczykowskib70da762019-01-28 15:20:48 -080018
Hungming Chenec203382020-02-13 19:15:33 +080019#include <android-base/result.h>
Maciej Żenczykowskie5b6b4d2020-02-05 02:00:38 -080020#include <errno.h>
Maciej Żenczykowskif1247382020-02-05 00:44:14 -080021#include <linux/if_ether.h>
Maciej Żenczykowskiba6ac9a2021-01-07 18:45:11 -080022#include <linux/if_link.h>
Maciej Żenczykowskib3e69d62020-02-05 02:44:16 -080023#include <linux/rtnetlink.h>
Patrick Rohrb791bd62022-03-29 21:18:31 +020024#include <tcutils/tcutils.h>
Maciej Żenczykowskif1247382020-02-05 00:44:14 -080025
Maciej Żenczykowski0a7dce82019-01-28 15:31:55 -080026#include <string>
27
Maciej Żenczykowskie5b6b4d2020-02-05 02:00:38 -080028#include "bpf/BpfUtils.h"
Maciej Żenczykowskie5b6b4d2020-02-05 02:00:38 -080029
Maciej Żenczykowskib70da762019-01-28 15:20:48 -080030namespace android {
31namespace net {
32
Maciej Żenczykowskif89e9112020-02-12 05:22:56 -080033inline int tcQdiscAddDevClsact(int ifIndex) {
34 return doTcQdiscClsact(ifIndex, RTM_NEWQDISC, NLM_F_EXCL | NLM_F_CREATE);
Maciej Żenczykowskib3e69d62020-02-05 02:44:16 -080035}
36
Maciej Żenczykowskif89e9112020-02-12 05:22:56 -080037inline int tcQdiscReplaceDevClsact(int ifIndex) {
38 return doTcQdiscClsact(ifIndex, RTM_NEWQDISC, NLM_F_CREATE | NLM_F_REPLACE);
Maciej Żenczykowskib3e69d62020-02-05 02:44:16 -080039}
40
Maciej Żenczykowskif89e9112020-02-12 05:22:56 -080041inline int tcQdiscDelDevClsact(int ifIndex) {
42 return doTcQdiscClsact(ifIndex, RTM_DELQDISC, 0);
Maciej Żenczykowskib3e69d62020-02-05 02:44:16 -080043}
Maciej Żenczykowskiff3308d2019-02-12 19:10:55 -080044
Maciej Żenczykowskib70da762019-01-28 15:20:48 -080045} // namespace net
46} // namespace android