<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>leodido.dev - Shell</title>
    <subtitle>Leo&#x27;s take on security, eBPF, Linux, kernel, and whatever tech he meets</subtitle>
    <link rel="self" type="application/atom+xml" href="https://leodido.dev/tags/shell/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://leodido.dev"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2022-05-24T00:00:00+00:00</updated>
    <id>https://leodido.dev/tags/shell/atom.xml</id>
    <entry xml:lang="en">
        <title>traffico</title>
        <published>2022-05-24T00:00:00+00:00</published>
        <updated>2022-05-24T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://leodido.dev/projects/traffico/"/>
        <id>https://leodido.dev/projects/traffico/</id>
        
        <content type="html" xml:base="https://leodido.dev/projects/traffico/">&lt;p&gt;traffico is a collection of tools to shape traffic on a network using traffic control &lt;code&gt;tc(8)&lt;&#x2F;code&gt;.
It can be used via a CLI tool (&lt;code&gt;traffico&lt;&#x2F;code&gt;) or as a CNI plugin (&lt;code&gt;traffico-cni&lt;&#x2F;code&gt;).
For a list of the available programs and what they do see the &lt;a href=&quot;https:&#x2F;&#x2F;leodido.dev&#x2F;projects&#x2F;traffico&#x2F;#built-in-programs&quot;&gt;Built-in programs&lt;&#x2F;a&gt; section.&lt;&#x2F;p&gt;
&lt;p&gt;The built-in programs are very opinionated and made for the needs of the authors but the framework
is flexible enough to be used for other purposes. You can add programs to the &lt;code&gt;bpf&#x2F;&lt;&#x2F;code&gt; directory
to extend it to other use cases.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;contact&quot;&gt;Contact&lt;a class=&quot;zola-anchor&quot; href=&quot;#contact&quot; aria-label=&quot;Anchor link for: contact&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;If you have problems, questions, ideas or suggestions, please contact us by
posting to https:&#x2F;&#x2F;github.com&#x2F;leodido&#x2F;traffico&#x2F;issues.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;download&quot;&gt;Download&lt;a class=&quot;zola-anchor&quot; href=&quot;#download&quot; aria-label=&quot;Anchor link for: download&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;To download the very latest source do this:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;git&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; clone https:&#x2F;&#x2F;github.com&#x2F;leodido&#x2F;traffico.git&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;authors&quot;&gt;Authors&lt;a class=&quot;zola-anchor&quot; href=&quot;#authors&quot; aria-label=&quot;Anchor link for: authors&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;Leonardo Di Donato&lt;&#x2F;li&gt;
&lt;li&gt;Lorenzo Fontana&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;usage&quot;&gt;Usage&lt;a class=&quot;zola-anchor&quot; href=&quot;#usage&quot; aria-label=&quot;Anchor link for: usage&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Traffico can be either used standalone or as a CNI plugin.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;traffico&quot;&gt;traffico&lt;a class=&quot;zola-anchor&quot; href=&quot;#traffico&quot; aria-label=&quot;Anchor link for: traffico&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;code&gt;traffico&lt;&#x2F;code&gt; is a CLI tool that can be used to load and unload the programs.
You can choose an interface and choose whether the program will be loaded in
&lt;code&gt;INGRESS&lt;&#x2F;code&gt; or &lt;code&gt;EGRESS&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Start with a standalone block program when the policy targets specific traffic
and should leave everything else alone:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;traffico&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-option&quot;&gt; --ifname=eth0 --at=INGRESS&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; block_private_ipv4&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Programs that accept runtime input (marked &lt;code&gt;[input]&lt;&#x2F;code&gt; in &lt;code&gt;--help&lt;&#x2F;code&gt;) take it as a second positional argument:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;traffico&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-option&quot;&gt; --ifname=eth0&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; block_ipv4&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 10.0.0.1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;traffico&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-option&quot;&gt; --ifname=eth0&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; block_port&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 443&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Use standalone allow programs when the interface should admit only the traffic
described by that one program:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;traffico&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-option&quot;&gt; --ifname=eth0&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; allow_ipv4&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 10.0.0.10&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;traffico&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-option&quot;&gt; --ifname=eth0&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; allow_proto tcp+udp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;traffico&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-option&quot;&gt; --ifname=eth0&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; allow_ethertype ipv4+arp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Use &lt;code&gt;--chain&lt;&#x2F;code&gt; when the policy needs multiple ordered stages. Chains that contain
L3&#x2F;L4 programs must start with the L2 gate &lt;code&gt;allow_ethertype&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;traffico&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-option&quot;&gt; --ifname=eth0 --chain&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;allow_ethertype:ipv4+arp,allow_port:443&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Chains compose checks linearly: each stage narrows the traffic that reaches the
next stage. That works well for single-path policies such as HTTPS to one
service:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;traffico&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-option&quot;&gt; --ifname=eth0 --at=EGRESS --chain&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;  &amp;quot;allow_ethertype:ipv4+arp,allow_ipv4:10.0.0.10,allow_proto:tcp,allow_port:443&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Or DNS to one resolver:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;traffico&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-option&quot;&gt; --ifname=eth0 --at=EGRESS --chain&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;  &amp;quot;allow_ethertype:ipv4+arp,allow_dns:10.0.0.53&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;These examples are alternative linear policies, not an additive multi-flow
allowlist. Full policies such as &quot;DNS to resolver OR HTTPS to service&quot; need
explicit OR composition.&lt;&#x2F;p&gt;
&lt;p&gt;Chain order is validated before attach. If a chain contains any L3&#x2F;L4 program,
slot 0 must be &lt;code&gt;allow_ethertype&lt;&#x2F;code&gt;, and the layer order must be &lt;code&gt;L2 -&amp;gt; L3 -&amp;gt; L4&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;traffico-cni&quot;&gt;traffico-cni&lt;a class=&quot;zola-anchor&quot; href=&quot;#traffico-cni&quot; aria-label=&quot;Anchor link for: traffico-cni&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;code&gt;traffico-cni&lt;&#x2F;code&gt; is a meta CNI plugin that allows the traffico programs to be used in CNI.&lt;&#x2F;p&gt;
&lt;p&gt;Meta means that &lt;code&gt;traffico-cni&lt;&#x2F;code&gt; does not create any interface for you,
it is intended to be used as a chained CNI plugin.&lt;&#x2F;p&gt;
&lt;p&gt;The plugin block to use &lt;code&gt;traffico-cni&lt;&#x2F;code&gt; is very similar to how &lt;code&gt;traffico&lt;&#x2F;code&gt; is
used as a CLI tool.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;json&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;    &amp;quot;type&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;traffico-cni&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;    &amp;quot;program&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;block_private_ipv4&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;    &amp;quot;attachPoint&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;ingress&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Programs that accept runtime input use the &lt;code&gt;&quot;input&quot;&lt;&#x2F;code&gt; field:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;json&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;    &amp;quot;type&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;traffico-cni&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;    &amp;quot;program&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;block_ipv4&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;    &amp;quot;input&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;10.0.0.1&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;    &amp;quot;attachPoint&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;egress&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Here&#x27;s an example CNI config file featuring &lt;code&gt;traffico-cni&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;json&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;    &amp;quot;name&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;mynetwork&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;    &amp;quot;cniVersion&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;0.4.0&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;    &amp;quot;plugins&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;: [&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;            &amp;quot;type&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;ptp&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;            &amp;quot;ipMasq&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-language&quot;&gt; true&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;            &amp;quot;ipam&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;: {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;                &amp;quot;type&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;host-local&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;                &amp;quot;subnet&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;10.10.10.0&#x2F;24&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;                &amp;quot;resolvConf&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;&#x2F;etc&#x2F;resolv.conf&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;                &amp;quot;routes&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;: [&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                    {&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt; &amp;quot;dst&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;0.0.0.0&#x2F;0&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                ]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            },&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;            &amp;quot;dns&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;: {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;                &amp;quot;nameservers&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;: [&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;&amp;quot;1.1.1.1&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;1.0.0.1&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        },&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;            &amp;quot;type&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;firewall&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        },&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;            &amp;quot;type&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;traffico-cni&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;            &amp;quot;program&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;block_private_ipv4&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;            &amp;quot;attachPoint&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;ingress&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        },&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-type z-property-name&quot;&gt;            &amp;quot;type&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;tc-redirect-tap&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;design-principles&quot;&gt;Design principles&lt;a class=&quot;zola-anchor&quot; href=&quot;#design-principles&quot; aria-label=&quot;Anchor link for: design-principles&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Principle&lt;&#x2F;th&gt;&lt;th&gt;Description&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Standalone vs chained&lt;&#x2F;td&gt;&lt;td&gt;Standalone programs are the only filter on the interface and handle all traffic types themselves. Chained programs pass traffic they do not handle to the next program, trusting that an upstream filter (typically &lt;code&gt;allow_ethertype&lt;&#x2F;code&gt;) already constrained it.&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Boundary failures&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;block_*&lt;&#x2F;code&gt; programs fail open (&lt;code&gt;TC_ACT_OK&lt;&#x2F;code&gt;) on truncated headers, unsupported protocols, and subsequent fragments because they target specific traffic. &lt;code&gt;allow_*&lt;&#x2F;code&gt; programs fail closed (&lt;code&gt;TC_ACT_SHOT&lt;&#x2F;code&gt;) on the same failures because they define permitted traffic.&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;L2 → L3 → L4 ordering&lt;&#x2F;td&gt;&lt;td&gt;Chains run cheapest and broadest checks first: &lt;code&gt;allow_ethertype&lt;&#x2F;code&gt; (L2), then &lt;code&gt;allow_proto&lt;&#x2F;code&gt; (L3), then &lt;code&gt;allow_port&lt;&#x2F;code&gt; or &lt;code&gt;allow_dns&lt;&#x2F;code&gt; (L4). &lt;code&gt;allow_ipv4&lt;&#x2F;code&gt; fits after L2 and alongside or after L3 protocol filtering.&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Non-IPv4 passthrough in chains&lt;&#x2F;td&gt;&lt;td&gt;In chains, L3 and L4 programs pass non-IPv4 traffic to the next program via &lt;code&gt;tail_call_next()&lt;&#x2F;code&gt;. L2 filtering is &lt;code&gt;allow_ethertype&lt;&#x2F;code&gt;&#x27;s job; ARP, IPv6, and other non-IPv4 traffic allowed by L2 must not be silently dropped downstream.&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h2 id=&quot;built-in-programs&quot;&gt;Built-in programs&lt;a class=&quot;zola-anchor&quot; href=&quot;#built-in-programs&quot; aria-label=&quot;Anchor link for: built-in-programs&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Program&lt;&#x2F;th&gt;&lt;th&gt;Description&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;allow_dns&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;Allows IPv4 DNS traffic (TCP&#x2F;UDP port 53) to the input resolver. Other IPv4 traffic passes through. Standalone mode blocks non-IPv4; chain mode passes non-IPv4 to the next stage.&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;allow_ethertype&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;L2 gatekeeper: drops frames whose outer EtherType is not in the allowed set (e.g., &lt;code&gt;ipv4+arp&lt;&#x2F;code&gt;). Required first when a chain contains L3&#x2F;L4 programs.&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;allow_ipv4&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;Allows IPv4 traffic to the input address, drops other IPv4 destinations except localhost (127.0.0.0&#x2F;8). Standalone mode blocks non-IPv4; chain mode passes non-IPv4 to the next stage.&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;allow_port&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;Allows IPv4 TCP&#x2F;UDP traffic to the input port. Other IPv4 protocols pass through. Standalone mode blocks non-IPv4; chain mode passes non-IPv4 to the next stage. TCP&#x2F;UDP subsequent fragments are blocked.&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;allow_proto&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;L3 gatekeeper: drops IPv4 packets whose IP protocol is not in the allowed set (e.g., &lt;code&gt;tcp+udp&lt;&#x2F;code&gt;). It unwraps supported VLAN&#x2F;QinQ tags before the IPv4 protocol check. Standalone mode blocks non-IPv4 after VLAN unwrap; chain mode passes it to the next stage.&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;block_private_ipv4&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;Blocks private IPv4 addresses subnets allowing only SSH access on port 22&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;block_ipv4&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;Drops packets with destination equal to the input IPv4 address&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;block_port&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;Drops packets with the destination port equal to the input port number&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;nop&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;A simple program that does nothing&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h3 id=&quot;notes-on-allow-ethertype&quot;&gt;Notes on &lt;code&gt;allow_ethertype&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#notes-on-allow-ethertype&quot; aria-label=&quot;Anchor link for: notes-on-allow-ethertype&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;strong&gt;Chain ordering:&lt;&#x2F;strong&gt; If a chain contains any L3&#x2F;L4 program, slot 0 must be &lt;code&gt;allow_ethertype&lt;&#x2F;code&gt;. Chain order must be non-decreasing by layer: &lt;code&gt;L2 -&amp;gt; L3 -&amp;gt; L4&lt;&#x2F;code&gt;. Same-layer programs are allowed, and chains may skip L3 after the L2 gate, such as &lt;code&gt;--chain &quot;allow_ethertype:ipv4+arp,allow_port:443&quot;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;VLAN-tagged networks:&lt;&#x2F;strong&gt; Standalone &lt;code&gt;allow_ethertype&lt;&#x2F;code&gt; compares the EtherType in the outer Ethernet header only; it does not unwrap VLAN tags or match the inner payload EtherType. Symbolic names &lt;code&gt;vlan&lt;&#x2F;code&gt; (0x8100) and &lt;code&gt;qinq&lt;&#x2F;code&gt; (0x88A8) are available for standalone filters. In multi-program chains, VLAN TPIDs are rejected because VLAN-aware parsing is not uniform across downstream programs. Example (standalone): &lt;code&gt;allow_ethertype ipv4+arp+vlan&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;notes-on-allow-proto&quot;&gt;Notes on &lt;code&gt;allow_proto&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#notes-on-allow-proto&quot; aria-label=&quot;Anchor link for: notes-on-allow-proto&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;strong&gt;Chain ordering:&lt;&#x2F;strong&gt; In a chain, &lt;code&gt;allow_proto&lt;&#x2F;code&gt; should be placed after &lt;code&gt;allow_ethertype&lt;&#x2F;code&gt; and before &lt;code&gt;allow_port&lt;&#x2F;code&gt;&#x2F;&lt;code&gt;allow_dns&lt;&#x2F;code&gt;. This gives &lt;code&gt;L2 -&amp;gt; L3 -&amp;gt; L4&lt;&#x2F;code&gt; ordering with cheapest checks first. Example: &lt;code&gt;--chain &quot;allow_ethertype:ipv4+arp,allow_proto:tcp+udp,allow_port:8080&quot;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;VLAN-tagged IPv4:&lt;&#x2F;strong&gt; &lt;code&gt;allow_proto&lt;&#x2F;code&gt; unwraps supported 802.1Q and QinQ tags before reading the IPv4 protocol. Truncated VLAN headers and unsupported additional VLAN nesting fail closed.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Non-IPv4 behavior:&lt;&#x2F;strong&gt; In standalone mode, non-IPv4 traffic is blocked after VLAN unwrap because the program is the complete policy. In chain mode, non-IPv4 traffic is passed to the next stage because L2 policy belongs to &lt;code&gt;allow_ethertype&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;build&quot;&gt;Build&lt;a class=&quot;zola-anchor&quot; href=&quot;#build&quot; aria-label=&quot;Anchor link for: build&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;To compile traffico from source you either provide your &lt;code&gt;vmlinux.h&lt;&#x2F;code&gt; in the
&lt;code&gt;vmlinux&#x2F;&lt;&#x2F;code&gt; directory (default option) or you configure the project to
generate one from your current Linux kernel:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;xmake&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; f&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-option&quot;&gt; --generate-vmlinux=y&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now you will be able to build traffico from source by running:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;xmake&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;In case you only want to compile the BPF programs you can do this:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;xmake&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-option&quot;&gt; -b&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; bpf&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;test&quot;&gt;Test&lt;a class=&quot;zola-anchor&quot; href=&quot;#test&quot; aria-label=&quot;Anchor link for: test&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;To run the test suite you can do this:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;xmake&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-option&quot;&gt; -b&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; test&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;xmake&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; run test&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The full test suite includes Scapy-backed advanced packet tests that exercise IP options, fragmentation, and protocol-specific behavior. These require the &lt;code&gt;python-scapy&lt;&#x2F;code&gt; (Arch) or &lt;code&gt;python3-scapy&lt;&#x2F;code&gt; (Ubuntu) package. If Scapy is not installed, the advanced tests are skipped automatically.&lt;&#x2F;p&gt;
</content>
        
    </entry>
</feed>
