#include <linux/idr.h>
#include <linux/kconfig.h>
#include <linux/mctp.h>
#include <linux/netdevice.h>
#include <linux/rtnetlink.h>
#include <linux/skbuff.h>
#include <uapi/linux/if_arp.h>
#include <net/mctp.h>
#include <net/mctpdevice.h>
#include <net/netlink.h>
#include <net/sock.h>
#include <trace/events/mctp.h>
static const unsigned int mctp_message_maxlen = …;
static const unsigned long mctp_key_lifetime = …;
static void mctp_flow_prepare_output(struct sk_buff *skb, struct mctp_dev *dev);
static int mctp_route_discard(struct mctp_route *route, struct sk_buff *skb)
{ … }
static struct mctp_sock *mctp_lookup_bind(struct net *net, struct sk_buff *skb)
{ … }
static bool mctp_key_match(struct mctp_sk_key *key, unsigned int net,
mctp_eid_t local, mctp_eid_t peer, u8 tag)
{ … }
static struct mctp_sk_key *mctp_lookup_key(struct net *net, struct sk_buff *skb,
unsigned int netid, mctp_eid_t peer,
unsigned long *irqflags)
__acquires(&key->lock)
{ … }
static struct mctp_sk_key *mctp_key_alloc(struct mctp_sock *msk,
unsigned int net,
mctp_eid_t local, mctp_eid_t peer,
u8 tag, gfp_t gfp)
{ … }
void mctp_key_unref(struct mctp_sk_key *key)
{ … }
static int mctp_key_add(struct mctp_sk_key *key, struct mctp_sock *msk)
{ … }
static void __mctp_key_done_in(struct mctp_sk_key *key, struct net *net,
unsigned long flags, unsigned long reason)
__releases(&key->lock)
{ … }
#ifdef CONFIG_MCTP_FLOWS
static void mctp_skb_set_flow(struct sk_buff *skb, struct mctp_sk_key *key)
{ … }
static void mctp_flow_prepare_output(struct sk_buff *skb, struct mctp_dev *dev)
{ … }
#else
static void mctp_skb_set_flow(struct sk_buff *skb, struct mctp_sk_key *key) {}
static void mctp_flow_prepare_output(struct sk_buff *skb, struct mctp_dev *dev) {}
#endif
static int mctp_frag_queue(struct mctp_sk_key *key, struct sk_buff *skb)
{ … }
static int mctp_route_input(struct mctp_route *route, struct sk_buff *skb)
{ … }
static unsigned int mctp_route_mtu(struct mctp_route *rt)
{ … }
static int mctp_route_output(struct mctp_route *route, struct sk_buff *skb)
{ … }
static void mctp_route_release(struct mctp_route *rt)
{ … }
static struct mctp_route *mctp_route_alloc(void)
{ … }
unsigned int mctp_default_net(struct net *net)
{ … }
int mctp_default_net_set(struct net *net, unsigned int index)
{ … }
static void mctp_reserve_tag(struct net *net, struct mctp_sk_key *key,
struct mctp_sock *msk)
{ … }
struct mctp_sk_key *mctp_alloc_local_tag(struct mctp_sock *msk,
unsigned int netid,
mctp_eid_t local, mctp_eid_t peer,
bool manual, u8 *tagp)
{ … }
static struct mctp_sk_key *mctp_lookup_prealloc_tag(struct mctp_sock *msk,
unsigned int netid,
mctp_eid_t daddr,
u8 req_tag, u8 *tagp)
{ … }
static bool mctp_rt_match_eid(struct mctp_route *rt,
unsigned int net, mctp_eid_t eid)
{ … }
static bool mctp_rt_compare_exact(struct mctp_route *rt1,
struct mctp_route *rt2)
{ … }
struct mctp_route *mctp_route_lookup(struct net *net, unsigned int dnet,
mctp_eid_t daddr)
{ … }
static struct mctp_route *mctp_route_lookup_null(struct net *net,
struct net_device *dev)
{ … }
static int mctp_do_fragment_route(struct mctp_route *rt, struct sk_buff *skb,
unsigned int mtu, u8 tag)
{ … }
int mctp_local_output(struct sock *sk, struct mctp_route *rt,
struct sk_buff *skb, mctp_eid_t daddr, u8 req_tag)
{ … }
static int mctp_route_add(struct mctp_dev *mdev, mctp_eid_t daddr_start,
unsigned int daddr_extent, unsigned int mtu,
unsigned char type)
{ … }
static int mctp_route_remove(struct mctp_dev *mdev, mctp_eid_t daddr_start,
unsigned int daddr_extent, unsigned char type)
{ … }
int mctp_route_add_local(struct mctp_dev *mdev, mctp_eid_t addr)
{ … }
int mctp_route_remove_local(struct mctp_dev *mdev, mctp_eid_t addr)
{ … }
void mctp_route_remove_dev(struct mctp_dev *mdev)
{ … }
static int mctp_pkttype_receive(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt,
struct net_device *orig_dev)
{ … }
static struct packet_type mctp_packet_type = …;
static const struct nla_policy rta_mctp_policy[RTA_MAX + 1] = …;
static int mctp_route_nlparse(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack,
struct nlattr **tb, struct rtmsg **rtm,
struct mctp_dev **mdev, mctp_eid_t *daddr_start)
{ … }
static const struct nla_policy rta_metrics_policy[RTAX_MAX + 1] = …;
static int mctp_newroute(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int mctp_delroute(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int mctp_fill_rtinfo(struct sk_buff *skb, struct mctp_route *rt,
u32 portid, u32 seq, int event, unsigned int flags)
{ … }
static int mctp_dump_rtinfo(struct sk_buff *skb, struct netlink_callback *cb)
{ … }
static int __net_init mctp_routes_net_init(struct net *net)
{ … }
static void __net_exit mctp_routes_net_exit(struct net *net)
{ … }
static struct pernet_operations mctp_net_ops = …;
int __init mctp_routes_init(void)
{ … }
void mctp_routes_exit(void)
{ … }
#if IS_ENABLED(CONFIG_MCTP_TEST)
#include "test/route-test.c"
#endif