{"id":2843,"date":"2022-12-20T15:17:28","date_gmt":"2022-12-20T18:17:28","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/simple-action-in-tc-man8\/"},"modified":"2022-12-20T15:17:28","modified_gmt":"2022-12-20T18:17:28","slug":"simple-action-in-tc-man8","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/simple-action-in-tc-man8\/","title":{"rendered":"Simple action in tc (man8)"},"content":{"rendered":"<h1 align=\"center\">Simple action in tc<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#OPTIONS\">OPTIONS<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">simple &#8211; basic example action<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:23%; margin-top: 1em\"><b>tc<\/b> &#8230; <b>action simple<\/b> [ <b>sdata<\/b> <i>STRING<\/i> ] [ <b>index<\/b> <i>INDEX<\/i> ] [ <i>CONTROL<\/i> ]<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><i>CONTROL<\/i> := { <b>reclassify<\/b> | <b>pipe<\/b> | <b>drop<\/b> | <b>continue<\/b> | <b>ok<\/b> }<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This is a pedagogical example rather than an actually useful action. Upon every access, it prints the given <i>STRING<\/i> which may be of arbitrary length.<\/p>\n<h2>OPTIONS <a name=\"OPTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>sdata<\/b> <i>STRING<\/i><\/p>\n<p style=\"margin-left:22%;\">The actual string to print.<\/p>\n<p style=\"margin-left:11%;\"><b>index<\/b> <i>INDEX<\/i><\/p>\n<p style=\"margin-left:22%;\">Optional action index value.<\/p>\n<p style=\"margin-left:11%;\"><i>CONTROL<\/i><\/p>\n<p style=\"margin-left:22%;\">Indicate how <b>tc<\/b> should proceed after executing the action. For a description of the possible <i>CONTROL<\/i> values, see <b>tc-actions<\/b>(8).<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The following example makes the kernel yell &#8220;Incoming ICMP!&#8221; every time it sees an incoming ICMP on eth0. Steps are:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"3%\">\n<p>1)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>Add an ingress qdisc point to eth0<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"3%\">\n<p>2)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>Start a chain on ingress of eth0 that first matches ICMP then invokes the simple action to shout.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"3%\">\n<p>3)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>display stats and show that no packet has been seen by the action<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"3%\">\n<p>4)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>Send one ping packet to google (expect to receive a response back)<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"3%\">\n<p>5)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>grep the logs to see the logged message<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"3%\">\n<p>6)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>display stats again and observe increment by 1<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\">hadi@noma1:$ tc qdisc add dev eth0 ingress <br \/> hadi@noma1:$tc filter add dev eth0 parent ffff: protocol ip prio 5 <\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>u32 match ip protocol 1 0xff flowid 1:1 action simple sdata &#8220;Incoming ICMP&#8221;<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\">hadi@noma1:$ sudo tc -s filter ls dev eth0 parent ffff: <br \/> filter protocol ip pref 5 u32 <br \/> filter protocol ip pref 5 u32 fh 800: ht divisor 1 <br \/> filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1 <br \/> match 00010000\/00ff0000 at 8<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"><\/td>\n<td width=\"77%\">\n<p>action order 1: Simple <Incoming ICMP><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"><\/td>\n<td width=\"77%\">\n<p>index 4 ref 1 bind 1 installed 29 sec used 29 sec<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"><\/td>\n<td width=\"77%\">\n<p>Action statistics:<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"> <\/td>\n<td width=\"77%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"><\/td>\n<td width=\"77%\">\n<p>Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"> <\/td>\n<td width=\"77%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"><\/td>\n<td width=\"77%\">\n<p>backlog 0b 0p requeues 0<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\">hadi@noma1$ ping -c 1 www.google.ca <br \/> PING www.google.ca (74.125.225.120) 56(84) bytes of data. <br \/> 64 bytes from ord08s08-in-f24.1e100.net (74.125.225.120): icmp_req=1 ttl=53 time=31.3 ms<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">&#8212; www.google.ca ping statistics &#8212; <br \/> 1 packets transmitted, 1 received, 0% packet loss, time 0ms <br \/> rtt min\/avg\/max\/mdev = 31.316\/31.316\/31.316\/0.000 ms<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">hadi@noma1$ dmesg | grep simple <br \/> [135354.473951] simple: Incoming ICMP_1<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">hadi@noma1$ sudo tc\/tc -s filter ls dev eth0 parent ffff: <br \/> filter protocol ip pref 5 u32 <br \/> filter protocol ip pref 5 u32 fh 800: ht divisor 1 <br \/> filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1 <br \/> match 00010000\/00ff0000 at 8<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>action order 1: Simple <Incoming ICMP><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>index 4 ref 1 bind 1 installed 206 sec used 67 sec<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>Action statistics:<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>Sent 84 bytes 1 pkt (dropped 0, overlimits 0 requeues 0)<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>backlog 0b 0p requeues 0<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>tc<\/b>(8) <b>tc-actions<\/b>(8)<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  simple &#8211; basic example action <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,52,4,193],"class_list":["post-2843","post","type-post","status-publish","format-standard","hentry","category-8-administracion-del-sistema","tag-5","tag-administracion","tag-man8","tag-tc-simple"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/2843","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=2843"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/2843\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=2843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=2843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=2843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}