summaryrefslogtreecommitdiffstats
path: root/src/vnet/fib/fib_entry_src.c
AgeCommit message (Expand)AuthorFilesLines
2018-10-29Fixing Exclusive dpo path issues added when via rpathVijayabhaskar Katamreddy1-4/+18
2018-10-27FIB: Sources must be keep in priority order, so re-sort after a vec_delNeale Ranns1-0/+2
2018-10-16FIB: use vlib-log for debuggingNeale Ranns1-2/+1
2018-03-20FIB Interpose SourceNeale Ranns1-149/+235
2018-03-13FIB: DVR paths are not considered L3 attachedNeale Ranns1-0/+10
2018-03-09MPLS Unifom modeNeale Ranns1-1/+3
2018-03-05IP6 link-local tableNeale Ranns1-5/+3
2018-01-18FIB Inherited SrouceNeale Ranns1-6/+347
2017-12-21fib: make deag entries urpf extemptFlorin Coras1-0/+4
2017-12-09BIER in non-MPLS netowrksNeale Ranns1-0/+1
2017-12-05Revert "FIB: optimise for src memory allocations"Neale Ranns1-131/+66
2017-11-26FIB: optimise for src memory allocationsNeale Ranns1-66/+131
2017-11-11MPLS disposition actions at the tail of unicast LSPsNeale Ranns1-1/+18
2017-11-09BIERNeale Ranns1-6/+8
2017-08-08L2 over MPLSNeale Ranns1-12/+4
2017-07-18FIB path preferenceNeale Ranns1-0/+18
2017-05-23ARP/ND entries for the same address on different interfaces (VPP-848)Neale Ranns1-184/+105
2017-05-02Use per-protocol default flow-hash config when the FIB table index is not knownNeale Ranns1-2/+17
2017-04-24Improve Load-Balance MAPsNeale Ranns1-7/+8
2017-04-07MPLS McastNeale Ranns1-78/+76
2017-03-17Attached hostsNeale Ranns1-0/+4
2017-03-06ioam: manycast using iOAM and SR (VPP-628)Shwetha Bhandari1-2/+3
2017-02-24FIB: 1) fix pool realloc during prefix export. 2) don't walk off the end of t...Neale Ranns1-2/+6
2017-02-13Basic support for LISP-GPE encapsulated NSH packetsFlorin Coras1-0/+1
2017-01-27IP Multicast FIB (mfib)Neale Ranns1-0/+4
2017-01-05FIB memory leaks (VPP-578)Neale Ranns1-0/+8
2016-12-28Reorganize source tree to use single autotools instanceDamjan Marion1-0/+1456
200; 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

# Copyright (c) 2016 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Traffic script for IPv6 sweep ping."""

import logging
import os
import sys

# pylint: disable=no-name-in-module
# pylint: disable=import-error
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)

from scapy.all import Ether
from scapy.layers.inet6 import IPv6, ICMPv6ND_NA, ICMPv6ND_NS
from scapy.layers.inet6 import ICMPv6NDOptDstLLAddr
from scapy.layers.inet6 import ICMPv6EchoRequest, ICMPv6EchoReply

from resources.libraries.python.PacketVerifier import RxQueue, TxQueue
from resources.libraries.python.PacketVerifier import checksum_equal
from resources.libraries.python.TrafficScriptArg import TrafficScriptArg


def main():
    # start_size - start size of the ICMPv6 echo data
    # end_size - end size of the ICMPv6 echo data
    # step - increment step
    args = TrafficScriptArg(['src_mac', 'dst_mac', 'src_ip', 'dst_ip',
                             'start_size', 'end_size', 'step'])

    rxq = RxQueue(args.get_arg('rx_if'))
    txq = TxQueue(args.get_arg('tx_if'))

    src_mac = args.get_arg('src_mac')
    dst_mac = args.get_arg('dst_mac')
    src_ip = args.get_arg('src_ip')
    dst_ip = args.get_arg('dst_ip')
    start_size = int(args.get_arg('start_size'))
    end_size = int(args.get_arg('end_size'))
    step = int(args.get_arg('step'))
    echo_id = 0xa
    # generate some random data buffer
    data = bytearray(os.urandom(end_size))

    # send ICMPv6 neighbor advertisement message
    sent_packets = []
    pkt_send = (Ether(src=src_mac, dst=dst_mac) /
                IPv6(src=src_ip, dst=dst_ip) /
                ICMPv6ND_NA(tgt=src_ip, R=0) /
                ICMPv6NDOptDstLLAddr(lladdr=src_mac))
    sent_packets.append(pkt_send)
    txq.send(pkt_send)

    # send ICMPv6 echo request with incremented data length and receive ICMPv6
    # echo reply
    for echo_seq in range(start_size, end_size + 1, step):
        pkt_send = (Ether(src=src_mac, dst=dst_mac) /
                    IPv6(src=src_ip, dst=dst_ip) /
                    ICMPv6EchoRequest(id=echo_id, seq=echo_seq,
                                      data=data[0:echo_seq]))
        sent_packets.append(pkt_send)
        txq.send(pkt_send)

        while True:
            ether = rxq.recv(ignore=sent_packets)
            if ether is None:
                raise RuntimeError('ICMPv6 echo reply seq {0} '
                                   'Rx timeout'.format(echo_seq))

            if ether.haslayer(ICMPv6ND_NS):
                # read another packet in the queue in case of ICMPv6ND_NS packet
                continue
            else:
                # otherwise process the current packet
                break

        if not ether.haslayer(IPv6):
            raise RuntimeError('Unexpected packet with no IPv6 layer '
                               'received: {0}'.format(ether.__repr__()))

        ipv6 = ether[IPv6]

        if not ipv6.haslayer(ICMPv6EchoReply):
            raise RuntimeError('Unexpected packet with no ICMPv6 echo reply '
                               'layer received: {0}'.format(ipv6.__repr__()))

        icmpv6 = ipv6[ICMPv6EchoReply]

        if icmpv6.id != echo_id or icmpv6.seq != echo_seq:
            raise RuntimeError('ICMPv6 echo reply with invalid data received: '
                               'ID {0} seq {1} should be ID {2} seq {3}, {0}'.
                               format(icmpv6.id, icmpv6.seq, echo_id,
                                      echo_seq))

        cksum = icmpv6.cksum
        del icmpv6.cksum
        tmp = ICMPv6EchoReply(str(icmpv6))
        if not checksum_equal(tmp.cksum, cksum):
            raise RuntimeError('Invalid checksum: {0} should be {1}'.
                               format(cksum, tmp.cksum))

        sent_packets.remove(pkt_send)

    sys.exit(0)


if __name__ == "__main__":
    main()