<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal">
<p dir="auto">Hi!</p>

<p dir="auto">Been trawling around the code, debugging this.</p>

<p dir="auto">Focusing on one example of a dropped flow:</p>

<p dir="auto">(NOTE: I changed the mac addresses and ips throughout all of this, as not to post anything sensitive):</p>

<p dir="auto">DEBUG: dropped update for: protocol: 4 vlan: 4 srcmac: d46a35311111 srcvli: 472 dest: 001f9ed20000 dstvli: 0 pktsize: 1057 samplerate: 16384<br>
DEBUG: rejected: FLOW,192.168.83.23,1000100,35001,d46a35311111,001f9ed20000,0x0800,4,4,176.1.2.3,212.1.2.3,6,0x00,125,62012,10443,0x18,1057,1039,16384</p>

<p dir="auto">Debugging sflow-to-rrd-handler first…</p>

<p dir="auto">sub getvlifrommactable is returning 0 because $mactable->{$infra}->{$vlan}->{$mac} is not defined for that destination mac.<br>
($mactable->{$infra}->{$vlan} is defined and does not contain that mac).</p>

<p dir="auto">So, we make a call to: <a href="https://ixpmanager.example.com/v4/sflow-db-mapper/learned-macs" style="color:#3983C4">https://ixpmanager.example.com/v4/sflow-db-mapper/learned-macs</a> with a valid API key.</p>

<p dir="auto">Sure enough, that mac is not in the returned list!</p>

<p dir="auto">…but it is in the database - for 2x vlans, which matches what I see in the MAC address table on the switch they are connected to:</p>

<p dir="auto">xxx-sr2#sh mac address-table int Po123</p>

<h2 style="font-size:1.2em">          Mac Address Table</h2>

<p dir="auto">Vlan    Mac Address       Type        Ports      Moves   Last Move</p>

<hr style="background:#333; background-image:linear-gradient(to right, #ccc, #333, #ccc); border:0; height:1px" height="1">

<p dir="auto">4    001f.9ed2.0000    DYNAMIC     Po123      1       11 days, 10:13:58 ago<br>
 300    001f.9ed2.0000    DYNAMIC     Po123      1       11 days, 10:13:58 ago<br>
Total Mac Addresses for this criterion: 2</p>

<p dir="auto">mysql> select * from l2address where mac='001f9ed20000';<br>
+----+-------------------+--------------+---------------------+----------+---------------------+<br>
| id | vlan_interface_id | mac          | firstseen           | lastseen | created             |<br>
+----+-------------------+--------------+---------------------+----------+---------------------+<br>
| 62 |                62 | 001f9ed20000 | 2018-06-20 15:44:14 | NULL     | 2018-06-20 15:47:14 |<br>
| 63 |               243 | 001f9ed20000 | 2018-06-20 15:44:14 | NULL     | 2018-06-20 15:47:14 |<br>
+----+-------------------+--------------+---------------------+----------+---------------------+<br>
2 rows in set (0.00 sec)</p>

<p dir="auto">So then we end up at sflowLearnedMacs():<br>
<a href="https://github.com/inex/IXP-Manager/blob/f9645b3d1bdcbecd76c24ca7867c3a033cfb017e/app/Http/Controllers/Api/V4/VlanInterfaceController.php#L76" style="color:#3983C4">https://github.com/inex/IXP-Manager/blob/f9645b3d1bdcbecd76c24ca7867c3a033cfb017e/app/Http/Controllers/Api/V4/VlanInterfaceController.php#L76</a></p>

<p dir="auto">Which in turn uses sflowLearnedMacsHash():<br>
<a href="https://github.com/inex/IXP-Manager/blob/f9645b3d1bdcbecd76c24ca7867c3a033cfb017e/database/Repositories/VlanInterface.php#L448" style="color:#3983C4">https://github.com/inex/IXP-Manager/blob/f9645b3d1bdcbecd76c24ca7867c3a033cfb017e/database/Repositories/VlanInterface.php#L448</a></p>

<p dir="auto">Which uses this query:</p>

<pre style="background-color:#F7F7F7; border-radius:5px 5px 5px 5px; margin-left:15px; margin-right:15px; max-width:90vw; overflow-x:auto; padding:5px" bgcolor="#F7F7F7"><code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0" bgcolor="#F7F7F7">    return $this->getEntityManager()->createQuery(
        "SELECT DISTINCT vli.id AS vliid, ma.mac AS mac, vl.number as tag, i.id as infrastructure
                FROM Entities\VirtualInterface vi
                    LEFT JOIN vi.VlanInterfaces vli
                    JOIN vi.MACAddresses ma
                    LEFT JOIN vli.Vlan vl
                    LEFT JOIN vl.Infrastructure i
                WHERE ma.mac IS NOT NULL
                    AND vli.id IS NOT NULL
                ORDER BY vliid"
    )->getArrayResult();
</code></pre>

<p dir="auto">How can one print out the SQL that generates as a string??</p>

<p dir="auto">Unable to work out how to get the exact query, I poked around the database and came up with something similar…</p>

<p dir="auto">mysql> SELECT l2.*, vli.id AS vli_id, vl.id AS vlan_id, vl.name AS vlan, vl.number AS vlan_num FROM l2address l2 LEFT JOIN vlaninterface vli on l2.vlan_interface_id = vli.id LEFT JOIN vlan vl ON vli.vlanid = vl.id LEFT JOIN infrastructure i ON vl.infrastructureid = i.id WHERE l2.mac='001f9ed20000';<br>
+----+-------------------+--------------+---------------------+----------+---------------------+--------+---------+----------------------+----------+<br>
| id | vlan_interface_id | mac          | firstseen           | lastseen | created             | vli_id | vlan_id | vlan                 | vlan_num |<br>
+----+-------------------+--------------+---------------------+----------+---------------------+--------+---------+----------------------+----------+<br>
| 62 |                62 | 001f9ed20000 | 2018-06-20 15:44:14 | NULL     | 2018-06-20 15:47:14 |     62 |       1 | LONAP Peering LAN #1 |        4 |<br>
| 63 |               243 | 001f9ed20000 | 2018-06-20 15:44:14 | NULL     | 2018-06-20 15:47:14 |    243 |      81 | P379                 |      379 |<br>
+----+-------------------+--------------+---------------------+----------+---------------------+--------+---------+----------------------+----------+<br>
2 rows in set (0.00 sec)</p>

<p dir="auto">So it seems as if the /v4/sflow-db-mapper/learned-macs call might not be returning all the macs it should, but I can’t quite pinpoint why….</p>

<p dir="auto">Any ideas?</p>

<p dir="auto">Thanks,</p>

<p dir="auto">Ian</p>
</div>
</div>
</body>
</html>