aboutsummaryrefslogtreecommitdiffstats
path: root/extras/selinux/vpp-custom.fc
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2019-09-06 13:43:16 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2019-10-03 08:41:20 +0000
commit5308ce13f6b070cb1e4558cb70b330ef548544cf (patch)
treec8d9f9baab257d95cb73229c3ee8eae03c9cceb4 /extras/selinux/vpp-custom.fc
parent68ac86e923ce55bcc0ea82c4b5a0e0ef83b56c23 (diff)
gbp: fix contract rule handling
Fix a memory leak when removing old GBP contract rules and make sure a GBP contract rule exists when matching the corresponding ACL rule. Type: fix Fixes: 13a08cc098 Change-Id: Iba67d573e69280ad998488a7a3d3462341c68ea4 Signed-off-by: Benoît Ganne <bganne@cisco.com> (cherry picked from commit 44ca60ecdba866160bebbc6c1eb983674819d429)
Diffstat (limited to 'extras/selinux/vpp-custom.fc')
0 files changed, 0 insertions, 0 deletions
lor: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#!/usr/bin/env python

import socket
import sys
import time

# action can be reflect or drop 
action = "drop"
test = 0

def test_data (data, n_rcvd):
    n_read = len (data);
    for i in range(n_read):
        expected = (n_rcvd + i) & 0xff
        byte_got = ord (data[i])
        if (byte_got != expected):
            print("Difference at byte {}. Expected {} got {}"
                  .format(n_rcvd + i, expected, byte_got))
    return n_read

def handle_connection (connection, client_address):
    print("Received connection from {}".format(repr(client_address)))
    n_rcvd = 0
    try:
        while True:
            data = connection.recv(4096)
            if not data:
                break;
            if (test == 1):
                n_rcvd += test_data (data, n_rcvd)
            if (action != "drop"):
                connection.sendall(data)
    finally:
        connection.close()
        
def run_server(ip, port):
    print("Starting server {}:{}".format(repr(ip), repr(port)))
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    server_address = (ip, int(port))
    sock.bind(server_address)
    sock.listen(1)
    
    while True:
        connection, client_address = sock.accept()
        handle_connection (connection, client_address)

def prepare_data():
    buf = []
    for i in range (0, pow(2, 16)):
        buf.append(i & 0xff)
    return bytearray(buf)

def run_client(ip, port):
    print("Starting client {}:{}".format(repr(ip), repr(port)))
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_address = (ip, port)
    sock.connect(server_address)
    
    data = prepare_data()
    n_rcvd = 0
    n_sent = len (data)
    try:
        sock.sendall(data)
        
        timeout = time.time() + 2
        while n_rcvd < n_sent and time.time() < timeout:
            tmp = sock.recv(1500)
            tmp = bytearray (tmp)
            n_read = len(tmp)
            for i in range(n_read):
                if (data[n_rcvd + i] != tmp[i]):
                    print("Difference at byte {}. Sent {} got {}"
                          .format(n_rcvd + i, data[n_rcvd + i], tmp[i]))
            n_rcvd += n_read
            
        if (n_rcvd < n_sent or n_rcvd > n_sent):
            print("Sent {} and got back {}".format(n_sent, n_rcvd))
        else:
            print("Got back what we've sent!!");
            
    finally:
        sock.close()
    
def run(mode, ip, port):
    if (mode == "server"):
        run_server (ip, port)
    elif (mode == "client"):
        run_client (ip, port)
    else:
        raise Exception("Unknown mode. Only client and server supported")

if __name__ == "__main__":
    if (len(sys.argv)) < 4:
        raise Exception("Usage: ./dummy_app <mode> <ip> <port> [<action> <test>]")
    if (len(sys.argv) == 6):
        action = sys.argv[4]
        test = int(sys.argv[5])

    run (sys.argv[1], sys.argv[2], int(sys.argv[3]))