summaryrefslogtreecommitdiff
path: root/oui-update.py
blob: 07add9f52a7072939f921afe4e3f03b6a32267ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# update-oui.py -- update netsniff-ng oui.conf from official IEEE OUI list
#
# Copyright (C) 2013 Tobias Klauser <tklauser@distanz.ch>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

import os
import sys
import re
import getopt
try:
    from urllib2 import urlopen             # Python 2.x
except ImportError:
    from urllib.request import urlopen      # Python 3.x

DEFAULT_OUPUT_FILE = "oui.conf"
DEFAULT_OUI_URL = "http://standards.ieee.org/develop/regauth/oui/oui.txt"

OUI_PATTERN = re.compile(b"^\s*([a-fA-F0-9]{2})-([a-fA-F0-9]{2})-([a-fA-F0-9]{2})\s+\(hex\)\s+(.*)$")

def usage():
    print("""usage: {0} [OPTION...]
available options:
    -f  force overwrite of existing file
    -o  set output file (default: {1})
    -u  set URL to fetch OUI list from (default: {2})
    -h  show this help and exit""".format(os.path.basename(sys.argv[0]),
                                          DEFAULT_OUPUT_FILE, DEFAULT_OUI_URL))

def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "fo:u:h")
    except getopt.GetoptError as err:
        print(str(err))
        usage()
        sys.exit(-1)

    overwrite = False
    output_file = DEFAULT_OUPUT_FILE
    oui_url = DEFAULT_OUI_URL
    for o, a in opts:
        if o == '-f':
            overwrite = True
        elif o == '-o':
            output_file = a
        elif o == '-u':
            oui_url = a
        elif o == '-h':
            usage()
            sys.exit(0)
        else:
            assert False, "unhandled option"

    if not overwrite and os.path.exists(output_file):
        print("Error: output file {} already exists".format(output_file))
        sys.exit(-1)

    print("Updating OUI information in {} from {}... ".format(output_file, oui_url))

    fh_url = urlopen(oui_url)

    ouis = []
    for line in fh_url:
        m = OUI_PATTERN.match(line)
        if m:
            oui = "0x{}{}{}".format(m.group(1), m.group(2), m.group(3))
            vendor = m.group(4).rstrip()
            ouis.append((oui, vendor))

    fh_file = open(output_file, 'w')
    for oui, vendor in sorted(ouis):
        fh_file.write("{}, {}\n".format(oui, vendor))

    fh_url.close()
    fh_file.close()

    print("{} OUIs written to {}".format(len(ouis), output_file))

if __name__ == '__main__':
    main()
. Devices that offload multipath routes need to be made aware of nexthop status changes. Otherwise, the device will keep forwarding packets to non-functional nexthops. Add the FIB_EVENT_NH_{ADD,DEL} events to the fib notification chain, which notify capable devices when they should add or delete a nexthop from their tables. Cc: Roopa Prabhu <roopa@cumulusnetworks.com> Cc: David Ahern <dsa@cumulusnetworks.com> Cc: Andy Gospodarek <andy@greyhouse.net> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Reviewed-by: Andy Gospodarek <gospo@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-08bridge: vlan tunnel id info range fill size calc cleanupsRoopa Prabhu1-18/+16 This fixes a bug and cleans up tunnelid range size calculation code by using consistent variable names and checks in size calculation and fill functions. tested for a few cases of vlan-vni range mappings: (output from patched iproute2): $bridge vlan showtunnel port vid tunid vxlan0 100-105 1000-1005 200 2000 210 2100 211-213 2100-2102 214 2104 216-217 2108-2109 219 2119 Fixes: efa5356b0d97 ("bridge: per vlan dst_metadata netlink support") Reported-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-08gro_cells: move to net/core/gro_cells.cEric Dumazet6-0/+100 We have many gro cells users, so lets move the code to avoid duplication. This creates a CONFIG_GRO_CELLS option. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-07Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller