10031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall/* 20031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * Copyright (C) 2012 The Android Open Source Project 30031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 40031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * Licensed under the Apache License, Version 2.0 (the "License"); 50031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * you may not use this file except in compliance with the License. 60031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * You may obtain a copy of the License at 70031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 80031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * http://www.apache.org/licenses/LICENSE-2.0 90031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 100031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * Unless required by applicable law or agreed to in writing, software 110031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * distributed under the License is distributed on an "AS IS" BASIS, 120031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * See the License for the specific language governing permissions and 140031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * limitations under the License. 150031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall */ 160031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 170031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall// #define LOG_NDEBUG 0 180031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 190031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall/* 200031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * MODUS OPERANDI 210031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * -------------- 220031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 230031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * IPTABLES command sequence: 240031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 250031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * iptables -F 260031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 278c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * iptables -t raw -F idletimer_PREROUTING 288c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * iptables -t mangle -F idletimer_POSTROUTING 290031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 300031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 318c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * iptables -t raw -N idletimer_PREROUTING 328c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * iptables -t mangle -N idletimer_POSTROUTING 330031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 348c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * iptables -t raw -D PREROUTING -j idletimer_PREROUTING 358c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * iptables -t mangle -D POSTROUTING -j idletimer_POSTROUTING 360031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 370031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 388c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * iptables -t raw -I PREROUTING -j idletimer_PREROUTING 398c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * iptables -t mangle -I POSTROUTING -j idletimer_POSTROUTING 400031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 410031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * # For notifications to work the lable name must match the name of a valid interface. 420031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * # If the label name does match an interface, the rules will be a no-op. 430031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 448c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * iptables -t raw -A idletimer_PREROUTING -i rmnet0 -j IDLETIMER --timeout 5 --label test-chain --send_nl_msg 1 458c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * iptables -t mangle -A idletimer_POSTROUTING -o rmnet0 -j IDLETIMER --timeout 5 --label test-chain --send_nl_msg 1 460031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 478c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * iptables -nxvL -t raw 488c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * iptables -nxvL -t mangle 490031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 500031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * ================= 510031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 520031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * ndc command sequence 530031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * ------------------ 540031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * ndc idletimer enable 5598f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai * ndc idletimer add <iface> <timeout> <class label> 5698f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai * ndc idletimer remove <iface> <timeout> <class label> 570031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 580031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * Monitor effect on the iptables chains after each step using: 598c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * iptables -nxvL -t raw 608c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * iptables -nxvL -t mangle 610031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 620031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * Remember that the timeout value has to be same at the time of the 630031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * removal. 640031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 658c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * ================= 668c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * 678c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * Verifying the iptables rule 688c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * --------------------------- 698c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * We want to make sure the iptable rules capture every packet. It can be 708c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * verified with tcpdump. First take a note of the pkts count for the two rules: 718c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * 728c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * adb shell iptables -t mangle -L idletimer_mangle_POSTROUTING -v && adb shell iptables -t raw -L idletimer_raw_PREROUTING -v 738c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * 748c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * And then, before any network traffics happen on the device, run tcpdump: 758c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * 768c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * adb shell tcpdump | tee tcpdump.log 778c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * 788c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * After a while run iptables commands again, you could then count the number 798c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * of incoming and outgoing packets captured by tcpdump, and compare that with 808c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * the numbers reported by iptables command. There shouldn't be too much 818c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * difference on these numbers, i.e., with 2000 packets captured it should 828c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * differ by less than 5. 838c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * 848c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * ================= 858c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai * 860031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * Note that currently if the name of the iface is incorrect, iptables 870031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * will setup rules without checking if it is the name of a valid 880031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * interface (although no notifications will ever be received). It is 890031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * the responsibility of code in Java land to ensure that the interface name 900031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * is correct. The benefit of this, is that idletimers can be setup on 910031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * interfaces than come and go. 920031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 930031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * A remove should be called for each add command issued during cleanup, as duplicate 940031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * entries of the rule may exist and will all have to removed. 950031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 960031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall */ 970031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 980031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#include <stdlib.h> 990031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#include <errno.h> 1000031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#include <sys/socket.h> 1010031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#include <sys/stat.h> 102001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand#include <sys/wait.h> 1030031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#include <fcntl.h> 1040031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#include <netinet/in.h> 1050031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#include <arpa/inet.h> 1060031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#include <string.h> 1070031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#include <cutils/properties.h> 1080031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 1090031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#define LOG_TAG "IdletimerController" 1100031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#include <cutils/log.h> 111001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand#include <logwrap/logwrap.h> 1120031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 1130031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#include "IdletimerController.h" 1140031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#include "NetdConstants.h" 1150031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 1168c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Baiconst char* IdletimerController::LOCAL_RAW_PREROUTING = "idletimer_raw_PREROUTING"; 1178c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Baiconst char* IdletimerController::LOCAL_MANGLE_POSTROUTING = "idletimer_mangle_POSTROUTING"; 1188e188ed5c989ddcc07f0f5e9839493c22d17e7b6Jeff Sharkey 1190031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP AbgrallIdletimerController::IdletimerController() { 1200031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall} 1210031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 1220031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP AbgrallIdletimerController::~IdletimerController() { 1230031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall} 1240031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall/* return 0 or non-zero */ 125001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchandint IdletimerController::runIpxtablesCmd(int argc, const char **argv) { 1260031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall int res; 1270031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 128001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand res = android_fork_execvp(argc, (char **)argv, NULL, false, false); 129001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand ALOGV("runCmd() res=%d", res); 1300031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall return res; 1310031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall} 1320031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 1330031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrallbool IdletimerController::setupIptablesHooks() { 1340031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall return true; 1350031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall} 1360031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 1370031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrallint IdletimerController::setDefaults() { 1388c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai int res; 139001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand const char *cmd1[] = { 140001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand IPTABLES_PATH, 141001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "-t", 142001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "raw", 143001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "-F", 144001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand LOCAL_RAW_PREROUTING 145001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand }; 146001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand res = runIpxtablesCmd(ARRAY_SIZE(cmd1), cmd1); 1478c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai 1488c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai if (res) 1498c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai return res; 1508c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai 151001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand const char *cmd2[] = { 152001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand IPTABLES_PATH, 153001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "-t", 154001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "mangle", 155001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "-F", 156001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand LOCAL_MANGLE_POSTROUTING 157001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand }; 158001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand res = runIpxtablesCmd(ARRAY_SIZE(cmd2), cmd2); 159001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand 1608c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai return res; 1610031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall} 1620031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 1630031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrallint IdletimerController::enableIdletimerControl() { 1640031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall int res = setDefaults(); 1650031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall return res; 1660031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall} 1670031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 1680031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrallint IdletimerController::disableIdletimerControl() { 1690031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall int res = setDefaults(); 1700031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall return res; 1710031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall} 1720031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 1730031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrallint IdletimerController::modifyInterfaceIdletimer(IptOp op, const char *iface, 17498f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai uint32_t timeout, 17598f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai const char *classLabel) { 1760031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall int res; 177001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand char timeout_str[11]; //enough to store any 32-bit unsigned decimal 178001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand 179001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand snprintf(timeout_str, sizeof(timeout_str), "%u", timeout); 180001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand 181001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand const char *cmd1[] = { 182001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand IPTABLES_PATH, 183001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "-t", 184001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "raw", 185001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand (op == IptOpAdd) ? "-A" : "-D", 186001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand LOCAL_RAW_PREROUTING, 187001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "-i", 188001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand iface, 189001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "-j", 190001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "IDLETIMER", 191001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "--timeout", 192001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand timeout_str, 193001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "--label", 194001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand classLabel, 195001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "--send_nl_msg", 196001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "1" 197001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand }; 198001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand res = runIpxtablesCmd(ARRAY_SIZE(cmd1), cmd1); 1990031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 2008c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai if (res) 2018c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai return res; 2028c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai 203001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand const char *cmd2[] = { 204001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand IPTABLES_PATH, 205001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "-t", 206001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "mangle", 207001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand (op == IptOpAdd) ? "-A" : "-D", 208001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand LOCAL_MANGLE_POSTROUTING, 209001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "-o", 210001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand iface, 211001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "-j", 212001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "IDLETIMER", 213001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "--timeout", 214001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand timeout_str, 215001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "--label", 216001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand classLabel, 217001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "--send_nl_msg", 218001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand "1" 219001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand }; 220001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand res = runIpxtablesCmd(ARRAY_SIZE(cmd2), cmd2); 2210031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 2220031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall return res; 2230031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall} 2240031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 22598f65d32b1530b4da6050e38d52f955710577efbHaoyu Baiint IdletimerController::addInterfaceIdletimer(const char *iface, 22698f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai uint32_t timeout, 22798f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai const char *classLabel) { 22898f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai return modifyInterfaceIdletimer(IptOpAdd, iface, timeout, classLabel); 2290031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall} 2300031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 23198f65d32b1530b4da6050e38d52f955710577efbHaoyu Baiint IdletimerController::removeInterfaceIdletimer(const char *iface, 23298f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai uint32_t timeout, 23398f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai const char *classLabel) { 23498f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai return modifyInterfaceIdletimer(IptOpDelete, iface, timeout, classLabel); 2350031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall} 236