Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arp log bump #11

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions fboss/agent/ArpHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ void ArpHandler::handlePacket(unique_ptr<RxPacket> pkt,
// Check to see if this IP address is in our ARP response table.
auto entry = vlan->getArpResponseTable()->getEntry(targetIP);
if (!entry) {
// The target IP does not refer to us.
VLOG(5) << "ignoring ARP message for " << targetIP.str()
// The target IP does not refer to us. This is common
// if there is a port/vlan mismatch, so log somewhat verbosely.
VLOG(3) << "ignoring ARP message for " << targetIP.str()
<< " on vlan " << pkt->getSrcVlan();
stats->port(port)->arpNotMine();
// Update the sender IP --> sender MAC entry in our ARP table
Expand Down
37 changes: 37 additions & 0 deletions fboss/agent/tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
======== FBOSS Python Tools ========

Requirements:
apt-get install python-ipaddr python-thrift

Need all of the thrift files:

export FBOSS= path to base of code

Generate the python bindings from the thrift files:
cd $FBOSS/fboss/agent/if
for p in *.thrift; do
thrift -I $FBOSS -r --gen py highres.thrift
echo $p done
done


######
# Apply a couple of fixups (fixups or ???)

# Dodge the "can't find generator 'cpp2' error"
sed -i -e '^namespace cpp2 facebook.fboss/#namespace cpp2 facebook.fboss/ \
$FBOSS/fboss/agent/if/*.thrift
# fboss.agent doesn't exist, but fboss.ctrl does
sed -i -e 's/^from fboss.agent/from fboss.ctrl/' \
$FBOSS/fboss/agent/tools/fboss_route.py


Now run the fboss_route command:
export FBOSS_IF=$FBOSS/fboss/agent/if/gen-py
PYTHONPATH=$FBOSS_IF/neteng/:$FBOSS/external/fbthrift/thrift/lib/py:$FBOSS_IF/:$FBOSS/external/fbthrift/thrift/lib/py python fboss_route.py


For example:
export FBOSS_IF=$FBOSS/fboss/agent/if/gen-py
export PYTHONPATH=$FBOSS_IF/neteng/:$FBOSS/external/fbthrift/thrift/lib/py:$FBOSS_IF/:$FBOSS/external/fbthrift/thrift/lib/py
python fboss_route.py host add 172.31.0.0/24 172.16.1.1
51 changes: 45 additions & 6 deletions fboss/agent/tools/fboss_route.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
# Copyright (C) 2004-present Facebook. All Rights Reserved

from __future__ import division
Expand All @@ -10,14 +11,15 @@

import contextlib
import ipaddr
import pdb

from argparse import ArgumentParser, ArgumentError
from contextlib import contextmanager
from thrift.transport import TSocket
from thrift.protocol import TBinaryProtocol
from fboss.agent import FbossCtrl
from fboss.agent.ttypes import IpPrefix
from fboss.agent.ttypes import UnicastRoute
from fboss.ctrl import FbossCtrl
from fboss.ctrl.ttypes import IpPrefix
from fboss.ctrl.ttypes import UnicastRoute
from facebook.network.Address.ttypes import BinaryAddress

DEFAULT_CLIENTID = 1
Expand Down Expand Up @@ -51,10 +53,28 @@ def del_route(args):
with get_client(args) as client:
client.deleteUnicastRoutes(args.client, [prefix])

def list_intf(args):
details = args.details
with get_client(args) as client:
#for intf in client.getInterfaceList():
for idx, intf in client.getAllInterfaces().iteritems():
print ("L3 Interface %d: %s" % (idx, str(intf)))

def list_routes(args):
details = args.details
with get_client(args) as client:
for route in client.getRouteTable():
print ("Route %s" % route)

def list_optics(args):
details = args.details
with get_client(args) as client:
for key,val in client.getTransceiverInfo([3]):
print ("Optic %d: %s" % (key, str(val)))

@contextlib.contextmanager
def get_client(args, timeout=5.0):
sock = TSocket.TSocket('localhost', args.port)
sock = TSocket.TSocket(args.host, args.port)
sock.setTimeout(timeout * 1000) # thrift timeout is in ms
protocol = TBinaryProtocol.TBinaryProtocol(sock)
transport = protocol.trans
Expand All @@ -70,8 +90,8 @@ def get_client(args, timeout=5.0):
help='the controller thrift port')
ap.add_argument('--client', '-c', type=int, default=DEFAULT_CLIENTID,
help='the client ID used to manipulate the routes')
ap.add_argument('host',
help='the controller hostname')
ap.add_argument('--host',
help='the controller hostname', default='localhost')
subparsers = ap.add_subparsers()

flush_parser = subparsers.add_parser(
Expand All @@ -93,5 +113,24 @@ def get_client(args, timeout=5.0):
del_parser.add_argument(
'prefix', help='The route prefix, i.e. "1.1.1.0/24" or "2001::0/64"')

list_parser = subparsers.add_parser(
'list_intf', help='list switch interfaces')
list_parser.set_defaults(func=list_intf)
list_parser.add_argument(
'--details', action='store_true', help='List all information about the interface', default=False)

list_route_parser = subparsers.add_parser(
'list_route', help='list switch routes')
list_route_parser.set_defaults(func=list_routes)
list_route_parser.add_argument(
'--details', action='store_true', help='List all information about the routes', default=False)

list_optic_parser = subparsers.add_parser(
'list_optic', help='list switch optics')
list_optic_parser.set_defaults(func=list_optics)
list_optic_parser.add_argument(
'--details', action='store_true', help='List all information about the optics', default=False)


args = ap.parse_args()
args.func(args)