30 Mar, 2020

2 commits

  • This patch adds functionality to configure routes for RPL source routing
    functionality. There is no IPIP functionality yet implemented which can
    be added later when the cases when to use IPv6 encapuslation comes more
    clear.

    Signed-off-by: Alexander Aring
    Signed-off-by: David S. Miller

    Alexander Aring
     
  • The build_state callback of lwtunnel doesn't contain the net namespace
    structure yet. This patch will add it so we can check on specific
    address configuration at creation time of rpl source routes.

    Signed-off-by: Alexander Aring
    Signed-off-by: David S. Miller

    Alexander Aring
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 3029 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

28 Apr, 2019

1 commit

  • Even if the NLA_F_NESTED flag was introduced more than 11 years ago, most
    netlink based interfaces (including recently added ones) are still not
    setting it in kernel generated messages. Without the flag, message parsers
    not aware of attribute semantics (e.g. wireshark dissector or libmnl's
    mnl_nlmsg_fprintf()) cannot recognize nested attributes and won't display
    the structure of their contents.

    Unfortunately we cannot just add the flag everywhere as there may be
    userspace applications which check nlattr::nla_type directly rather than
    through a helper masking out the flags. Therefore the patch renames
    nla_nest_start() to nla_nest_start_noflag() and introduces nla_nest_start()
    as a wrapper adding NLA_F_NESTED. The calls which add NLA_F_NESTED manually
    are rewritten to use nla_nest_start().

    Except for changes in include/net/netlink.h, the patch was generated using
    this semantic patch:

    @@ expression E1, E2; @@
    -nla_nest_start(E1, E2)
    +nla_nest_start_noflag(E1, E2)

    @@ expression E1, E2; @@
    -nla_nest_start_noflag(E1, E2 | NLA_F_NESTED)
    +nla_nest_start(E1, E2)

    Signed-off-by: Michal Kubecek
    Acked-by: Jiri Pirko
    Acked-by: David Ahern
    Signed-off-by: David S. Miller

    Michal Kubecek
     

24 Apr, 2019

1 commit

  • Currently, lwtunnel_fill_encap hardcodes the encap and encap type
    attributes as RTA_ENCAP and RTA_ENCAP_TYPE, respectively. The nexthop
    objects want to re-use this code but the encap attributes passed to
    userspace as NHA_ENCAP and NHA_ENCAP_TYPE. Since that is the only
    difference, change lwtunnel_fill_encap to take the attribute type as
    an input.

    Signed-off-by: David Ahern
    Signed-off-by: David S. Miller

    David Ahern
     

23 Apr, 2019

1 commit


25 Feb, 2019

1 commit


08 Aug, 2017

2 commits

  • This patch implements a new type of lightweight tunnel named seg6local.
    A seg6local lwt is defined by a type of action and a set of parameters.
    The action represents the operation to perform on the packets matching the
    lwt's route, and is not necessarily an encapsulation. The set of parameters
    are arguments for the processing function.

    Each action is defined in a struct seg6_action_desc within
    seg6_action_table[]. This structure contains the action, mandatory
    attributes, the processing function, and a static headroom size required by
    the action. The mandatory attributes are encoded as a bitmask field. The
    static headroom is set to a non-zero value when the processing function
    always add a constant number of bytes to the skb (e.g. the header size for
    encapsulations).

    To facilitate rtnetlink-related operations such as parsing, fill_encap,
    and cmp_encap, each type of action parameter is associated to three
    function pointers, in seg6_action_params[].

    All actions defined in seg6_local.h are detailed in [1].

    [1] https://tools.ietf.org/html/draft-filsfils-spring-srv6-network-programming-01

    Signed-off-by: David Lebrun
    Signed-off-by: David S. Miller

    David Lebrun
     
  • Signed-off-by: Roopa Prabhu
    Signed-off-by: David S. Miller

    Roopa Prabhu
     

30 May, 2017

2 commits


01 May, 2017

1 commit

  • We recently added a check to see if nla_nest_start() fails. There are
    two issues with that. First, if it fails then I don't think we should
    call nla_nest_cancel(). Second, it's slightly convoluted but the
    current code returns success but we should return -EMSGSIZE instead.

    Fixes: a50fe0ffd76f ("lwtunnel: check return value of nla_nest_start")
    Signed-off-by: Dan Carpenter
    Acked-by: David Ahern
    Signed-off-by: David S. Miller

    Dan Carpenter
     

25 Apr, 2017

1 commit

  • Function nla_nest_start() may return a NULL pointer on error. However,
    in function lwtunnel_fill_encap(), the return value of nla_nest_start()
    is not validated before it is used. This patch checks the return value
    of nla_nest_start() against NULL.

    Signed-off-by: Pan Bian
    Signed-off-by: David S. Miller

    Pan Bian
     

14 Mar, 2017

1 commit

  • silences the below warning:
    net/core/lwtunnel.c: In function ‘lwtunnel_valid_encap_type_attr’:
    net/core/lwtunnel.c:165:17: warning: variable ‘nla’ set but not used
    [-Wunused-but-set-variable]

    Fixes: 9ed59592e3e3 ("lwtunnel: fix autoload of lwt modules")
    Signed-off-by: Roopa Prabhu
    Signed-off-by: David S. Miller

    Roopa Prabhu
     

31 Jan, 2017

1 commit


25 Jan, 2017

1 commit

  • When attempting to free lwtunnel state after the module for the encap
    has been unloaded an oops occurs:

    BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
    IP: lwtstate_free+0x18/0x40
    [..]
    task: ffff88003e372380 task.stack: ffffc900001fc000
    RIP: 0010:lwtstate_free+0x18/0x40
    RSP: 0018:ffff88003fd83e88 EFLAGS: 00010246
    RAX: 0000000000000000 RBX: ffff88002bbb3380 RCX: ffff88000c91a300
    [..]
    Call Trace:

    free_fib_info_rcu+0x195/0x1a0
    ? rt_fibinfo_free+0x50/0x50
    rcu_process_callbacks+0x2d3/0x850
    ? rcu_process_callbacks+0x296/0x850
    __do_softirq+0xe4/0x4cb
    irq_exit+0xb0/0xc0
    smp_apic_timer_interrupt+0x3d/0x50
    apic_timer_interrupt+0x93/0xa0
    [..]
    Code: e8 6e c6 fc ff 89 d8 5b 5d c3 bb de ff ff ff eb f4 66 90 66 66 66 66 90 55 48 89 e5 53 0f b7 07 48 89 fb 48 8b 04 c5 00 81 d5 81 8b 40 08 48 85 c0 74 13 ff d0 48 8d 7b 20 be 20 00 00 00 e8

    The problem is after the module for the encap can be unloaded the
    corresponding ops is removed and is thus NULL here.

    Modules implementing lwtunnel ops should not be allowed to unload
    while there is state alive using those ops, so grab the module
    reference for the ops on creating lwtunnel state and of course release
    the reference when freeing the state.

    Fixes: 1104d9ba443a ("lwtunnel: Add destroy state operation")
    Signed-off-by: Robert Shearman
    Signed-off-by: David S. Miller

    Robert Shearman
     

19 Jan, 2017

1 commit

  • Trying to add an mpls encap route when the MPLS modules are not loaded
    hangs. For example:

    CONFIG_MPLS=y
    CONFIG_NET_MPLS_GSO=m
    CONFIG_MPLS_ROUTING=m
    CONFIG_MPLS_IPTUNNEL=m

    $ ip route add 10.10.10.10/32 encap mpls 100 via inet 10.100.1.2

    The ip command hangs:
    root 880 826 0 21:25 pts/0 00:00:00 ip route add 10.10.10.10/32 encap mpls 100 via inet 10.100.1.2

    $ cat /proc/880/stack
    [] call_usermodehelper_exec+0xd6/0x134
    [] __request_module+0x27b/0x30a
    [] lwtunnel_build_state+0xe4/0x178
    [] fib_create_info+0x47f/0xdd4
    [] fib_table_insert+0x90/0x41f
    [] inet_rtm_newroute+0x4b/0x52
    ...

    modprobe is trying to load rtnl-lwt-MPLS:

    root 881 5 0 21:25 ? 00:00:00 /sbin/modprobe -q -- rtnl-lwt-MPLS

    and it hangs after loading mpls_router:

    $ cat /proc/881/stack
    [] rtnl_lock+0x12/0x14
    [] register_netdevice_notifier+0x16/0x179
    [] mpls_init+0x25/0x1000 [mpls_router]
    [] do_one_initcall+0x8e/0x13f
    [] do_init_module+0x5a/0x1e5
    [] load_module+0x13bd/0x17d6
    ...

    The problem is that lwtunnel_build_state is called with rtnl lock
    held preventing mpls_init from registering.

    Given the potential references held by the time lwtunnel_build_state it
    can not drop the rtnl lock to the load module. So, extract the module
    loading code from lwtunnel_build_state into a new function to validate
    the encap type. The new function is called while converting the user
    request into a fib_config which is well before any table, device or
    fib entries are examined.

    Fixes: 745041e2aaf1 ("lwtunnel: autoload of lwt modules")
    Signed-off-by: David Ahern
    Signed-off-by: David S. Miller

    David Ahern
     

02 Dec, 2016

1 commit

  • Registers new BPF program types which correspond to the LWT hooks:
    - BPF_PROG_TYPE_LWT_IN => dst_input()
    - BPF_PROG_TYPE_LWT_OUT => dst_output()
    - BPF_PROG_TYPE_LWT_XMIT => lwtunnel_xmit()

    The separate program types are required to differentiate between the
    capabilities each LWT hook allows:

    * Programs attached to dst_input() or dst_output() are restricted and
    may only read the data of an skb. This prevent modification and
    possible invalidation of already validated packet headers on receive
    and the construction of illegal headers while the IP headers are
    still being assembled.

    * Programs attached to lwtunnel_xmit() are allowed to modify packet
    content as well as prepending an L2 header via a newly introduced
    helper bpf_skb_change_head(). This is safe as lwtunnel_xmit() is
    invoked after the IP header has been assembled completely.

    All BPF programs receive an skb with L3 headers attached and may return
    one of the following error codes:

    BPF_OK - Continue routing as per nexthop
    BPF_DROP - Drop skb and return EPERM
    BPF_REDIRECT - Redirect skb to device as per redirect() helper.
    (Only valid in lwtunnel_xmit() context)

    The return codes are binary compatible with their TC_ACT_
    relatives to ease compatibility.

    Signed-off-by: Thomas Graf
    Acked-by: Alexei Starovoitov
    Acked-by: Daniel Borkmann
    Signed-off-by: David S. Miller

    Thomas Graf
     

10 Nov, 2016

1 commit

  • This patch creates a new type of interfaceless lightweight tunnel (SEG6),
    enabling the encapsulation and injection of SRH within locally emitted
    packets and forwarded packets.

    >From a configuration viewpoint, a seg6 tunnel would be configured as follows:

    ip -6 ro ad fc00::1/128 encap seg6 mode encap segs fc42::1,fc42::2,fc42::3 dev eth0

    Any packet whose destination address is fc00::1 would thus be encapsulated
    within an outer IPv6 header containing the SRH with three segments, and would
    actually be routed to the first segment of the list. If `mode inline' was
    specified instead of `mode encap', then the SRH would be directly inserted
    after the IPv6 header without outer encapsulation.

    The inline mode is only available if CONFIG_IPV6_SEG6_INLINE is enabled. This
    feature was made configurable because direct header insertion may break
    several mechanisms such as PMTUD or IPSec AH.

    Signed-off-by: David Lebrun
    Signed-off-by: David S. Miller

    David Lebrun
     

16 Oct, 2016

1 commit

  • Users of lwt tunnels may set up some secondary state in build_state
    function. Add a corresponding destroy_state function to allow users to
    clean up state. This destroy state function is called from lwstate_free.
    Also, we now free lwstate using kfree_rcu so user can assume structure
    is not freed before rcu.

    Acked-by: Roopa Prabhu
    Signed-off-by: Tom Herbert
    Signed-off-by: David S. Miller

    Tom Herbert
     

31 Aug, 2016

1 commit

  • Today mpls iptunnel lwtunnel_output redirect expects the tunnel
    output function to handle fragmentation. This is ok but can be
    avoided if we did not do the mpls output redirect too early.
    ie we could wait until ip fragmentation is done and then call
    mpls output for each ip fragment.

    To make this work we will need,
    1) the lwtunnel state to carry encap headroom
    2) and do the redirect to the encap output handler on the ip fragment
    (essentially do the output redirect after fragmentation)

    This patch adds tunnel headroom in lwtstate to make sure we
    account for tunnel data in mtu calculations during fragmentation
    and adds new xmit redirect handler to redirect to lwtunnel xmit func
    after ip fragmentation.

    This includes IPV6 and some mtu fixes and testing from David Ahern.

    Signed-off-by: Roopa Prabhu
    Signed-off-by: David Ahern
    Signed-off-by: David S. Miller

    Roopa Prabhu
     

22 Feb, 2016

1 commit

  • The lwt implementations using net devices can autoload using the
    existing mechanism using IFLA_INFO_KIND. However, there's no mechanism
    that lwt modules not using net devices can use.

    Therefore, add the ability to autoload modules registering lwt
    operations for lwt implementations not using a net device so that
    users don't have to manually load the modules.

    Only users with the CAP_NET_ADMIN capability can cause modules to be
    loaded, which is ensured by rtnetlink_rcv_msg rejecting non-RTM_GETxxx
    messages for users without this capability, and by
    lwtunnel_build_state not being called in response to RTM_GETxxx
    messages.

    Signed-off-by: Robert Shearman
    Signed-off-by: David S. Miller

    Robert Shearman
     

08 Oct, 2015

1 commit


25 Aug, 2015

1 commit

  • Add cfg and family arguments to lwt build state functions. cfg is a void
    pointer and will either be a pointer to a fib_config or fib6_config
    structure. The family parameter indicates which one (either AF_INET
    or AF_INET6).

    LWT encpasulation implementation may use the fib configuration to build
    the LWT state.

    Signed-off-by: Tom Herbert
    Signed-off-by: David S. Miller

    Tom Herbert
     

21 Aug, 2015

1 commit

  • Currently, the lwtunnel state resides in per-protocol data. This is
    a problem if we encapsulate ipv6 traffic in an ipv4 tunnel (or vice versa).
    The xmit function of the tunnel does not know whether the packet has been
    routed to it by ipv4 or ipv6, yet it needs the lwtstate data. Moving the
    lwtstate data to dst_entry makes such inter-protocol tunneling possible.

    As a bonus, this brings a nice diffstat.

    Signed-off-by: Jiri Benc
    Acked-by: Roopa Prabhu
    Acked-by: Thomas Graf
    Signed-off-by: David S. Miller

    Jiri Benc
     

18 Aug, 2015

1 commit

  • This patch adds the capability to redirect dst input in the same way
    that dst output is redirected by LWT.

    Also, save the original dst.input and and dst.out when setting up
    lwtunnel redirection. These can be called by the client as a pass-
    through.

    Signed-off-by: Tom Herbert
    Signed-off-by: David S. Miller

    Tom Herbert
     

04 Aug, 2015

1 commit

  • In the locally-generated packet path skb->protocol may not be set and
    this is required for the lwtunnel encap in order to get the lwtstate.

    This would otherwise have been set by ip_output or ip6_output so set
    skb->protocol prior to calling the lwtunnel encap
    function. Additionally set skb->dev in case it is needed further down
    the transmit path.

    Signed-off-by: Robert Shearman
    Signed-off-by: David S. Miller

    Robert Shearman
     

30 Jul, 2015

1 commit


27 Jul, 2015

1 commit


22 Jul, 2015

2 commits

  • This patch introduces lwtunnel_output function to call corresponding
    lwtunnels output function to xmit the packet.

    It adds two variants lwtunnel_output and lwtunnel_output6 for ipv4 and
    ipv6 respectively today. But this is subject to change when lwtstate will
    reside in dst or dst_metadata (as per upstream discussions).

    Signed-off-by: Roopa Prabhu
    Signed-off-by: David S. Miller

    Roopa Prabhu
     
  • Provides infrastructure to parse/dump/store encap information for
    light weight tunnels like mpls. Encap information for such tunnels
    is associated with fib routes.

    This infrastructure is based on previous suggestions from
    Eric Biederman to follow the xfrm infrastructure.

    Signed-off-by: Roopa Prabhu
    Signed-off-by: David S. Miller

    Roopa Prabhu