Add tcam test, fix tcam
This commit is contained in:
20
docs/core/metadata_lookup.md
Normal file
20
docs/core/metadata_lookup.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Metadata Lookup
|
||||
|
||||
Metadata lookup is responsible for determining what operations to do to the
|
||||
packet, what data to append to the packet (ip address, port). It also stores
|
||||
the keys and counters for crypto, and increments the counters in the case of
|
||||
packet that are encrypted.
|
||||
|
||||
The packet types we care about are:
|
||||
|
||||
1. Incoming IP frames to be encrypted, check dest_ip
|
||||
2. Incoming Wireguard frames to be decrypted, check source ip, wireguard type
|
||||
3. Incoming Wireguard frames to go to cpu, check source ip, wireguard type,
|
||||
|
||||
So really we need to check the IP addreses, and the wireguard info. We can use a TCAM to check
|
||||
if they match. for the wireguard packets, we want a different rule for the type 4 packets than
|
||||
the other types, since all other types go to cpu and type 4 gets decrypted.
|
||||
|
||||
So in terms of searching, we need to search the source/dest ip, and wireguard type. Since 0 is
|
||||
an invalid wireguard type, we know that if the type is 0 then it was not a wireguard packet.
|
||||
|
||||
@@ -52,4 +52,4 @@ be 0. The outputs will either match the metadata rules or not, so we don't care
|
||||
block.
|
||||
|
||||
The pattern specifically is IPv4 Ethertype (No VLAN), IHL 5 (No options), UDP protocol,
|
||||
Wireguard dest port, and wireguard message type 4.
|
||||
Wireguard dest port, and wireguard message type 4.
|
||||
|
||||
21
docs/core/tcam.md
Normal file
21
docs/core/tcam.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# TCAM
|
||||
|
||||
we need to design a tcam for this though. the tcam does not need to store any data, the result
|
||||
we are looking for is a simple present or not present, we will look up the result in a separate
|
||||
memory after the fact.
|
||||
|
||||
We need to program the value and the mask. But really, we program value_x and value_y. X is the
|
||||
inverse of the data, and y is the data.
|
||||
|
||||
There are two comparisons, both need to be 0 for there to be a match
|
||||
|
||||
`&~((d & x) | (~d & y)`
|
||||
|
||||
to get the match for all bits, we and them all together.
|
||||
|
||||
So there are two interfaces, the programming interface and the search interface.
|
||||
|
||||
programming interface consists of read data, write data, read enable, write enable, and addresss.
|
||||
|
||||
The search interface consists of search data, and the outputs are valid, match and
|
||||
key.
|
||||
@@ -1,6 +1,6 @@
|
||||
<mxfile host="Electron" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/29.3.0 Chrome/140.0.7339.249 Electron/38.7.2 Safari/537.36">
|
||||
<diagram name="Page-1" id="72PB9eZoycvEeqRRA-Ze">
|
||||
<mxGraphModel dx="1284" dy="863" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<mxGraphModel dx="790" dy="531" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
@@ -121,17 +121,16 @@
|
||||
<mxPoint x="-5" y="-10" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7ZK-1vDvfmA7mbs2EBc0-75" edge="1" parent="1" source="7ZK-1vDvfmA7mbs2EBc0-18" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.75;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" target="7ZK-1vDvfmA7mbs2EBc0-74">
|
||||
<mxCell id="7ZK-1vDvfmA7mbs2EBc0-75" edge="1" parent="1" source="7ZK-1vDvfmA7mbs2EBc0-21" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" target="7ZK-1vDvfmA7mbs2EBc0-74">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="300" y="350" />
|
||||
<mxPoint x="300" y="460" />
|
||||
<mxPoint x="480" y="460" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7ZK-1vDvfmA7mbs2EBc0-76" connectable="0" parent="7ZK-1vDvfmA7mbs2EBc0-75" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" value="tag" vertex="1">
|
||||
<mxGeometry relative="1" x="-0.2126" as="geometry">
|
||||
<mxPoint x="166" y="-10" as="offset" />
|
||||
<mxPoint x="95" y="-10" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7ZK-1vDvfmA7mbs2EBc0-18" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="Parser" vertex="1">
|
||||
|
||||
Reference in New Issue
Block a user