mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 01:53:29 +02:00
net: mctp: pass net into route creation
We may not have a mdev pointer, from which we currently extract the net. Instead, pass the net directly. Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Link: https://patch.msgid.link/20250702-dev-forwarding-v5-10-1468191da8a4@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
9b4a8c38f4
commit
48e6aa60bf
|
|
@ -1086,12 +1086,11 @@ int mctp_local_output(struct sock *sk, struct mctp_dst *dst,
|
|||
}
|
||||
|
||||
/* route management */
|
||||
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_add(struct net *net, struct mctp_dev *mdev,
|
||||
mctp_eid_t daddr_start, unsigned int daddr_extent,
|
||||
unsigned int mtu, unsigned char type)
|
||||
{
|
||||
int (*rtfn)(struct mctp_dst *dst, struct sk_buff *skb);
|
||||
struct net *net = dev_net(mdev->dev);
|
||||
struct mctp_route *rt, *ert;
|
||||
|
||||
if (!mctp_address_unicast(daddr_start))
|
||||
|
|
@ -1138,10 +1137,10 @@ static int mctp_route_add(struct mctp_dev *mdev, mctp_eid_t daddr_start,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mctp_route_remove(struct mctp_dev *mdev, mctp_eid_t daddr_start,
|
||||
unsigned int daddr_extent, unsigned char type)
|
||||
static int mctp_route_remove(struct net *net, struct mctp_dev *mdev,
|
||||
mctp_eid_t daddr_start, unsigned int daddr_extent,
|
||||
unsigned char type)
|
||||
{
|
||||
struct net *net = dev_net(mdev->dev);
|
||||
struct mctp_route *rt, *tmp;
|
||||
mctp_eid_t daddr_end;
|
||||
bool dropped;
|
||||
|
|
@ -1170,12 +1169,12 @@ static int mctp_route_remove(struct mctp_dev *mdev, mctp_eid_t daddr_start,
|
|||
|
||||
int mctp_route_add_local(struct mctp_dev *mdev, mctp_eid_t addr)
|
||||
{
|
||||
return mctp_route_add(mdev, addr, 0, 0, RTN_LOCAL);
|
||||
return mctp_route_add(dev_net(mdev->dev), mdev, addr, 0, 0, RTN_LOCAL);
|
||||
}
|
||||
|
||||
int mctp_route_remove_local(struct mctp_dev *mdev, mctp_eid_t addr)
|
||||
{
|
||||
return mctp_route_remove(mdev, addr, 0, RTN_LOCAL);
|
||||
return mctp_route_remove(dev_net(mdev->dev), mdev, addr, 0, RTN_LOCAL);
|
||||
}
|
||||
|
||||
/* removes all entries for a given device */
|
||||
|
|
@ -1284,12 +1283,11 @@ static const struct nla_policy rta_mctp_policy[RTA_MAX + 1] = {
|
|||
/* Common part for RTM_NEWROUTE and RTM_DELROUTE parsing.
|
||||
* tb must hold RTA_MAX+1 elements.
|
||||
*/
|
||||
static int mctp_route_nlparse(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
static int mctp_route_nlparse(struct net *net, struct nlmsghdr *nlh,
|
||||
struct netlink_ext_ack *extack,
|
||||
struct nlattr **tb, struct rtmsg **rtm,
|
||||
struct mctp_dev **mdev, mctp_eid_t *daddr_start)
|
||||
{
|
||||
struct net *net = sock_net(skb->sk);
|
||||
struct net_device *dev;
|
||||
unsigned int ifindex;
|
||||
int rc;
|
||||
|
|
@ -1343,6 +1341,7 @@ 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)
|
||||
{
|
||||
struct net *net = sock_net(skb->sk);
|
||||
struct nlattr *tb[RTA_MAX + 1];
|
||||
struct nlattr *tbx[RTAX_MAX + 1];
|
||||
mctp_eid_t daddr_start;
|
||||
|
|
@ -1351,7 +1350,7 @@ static int mctp_newroute(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|||
unsigned int mtu;
|
||||
int rc;
|
||||
|
||||
rc = mctp_route_nlparse(skb, nlh, extack, tb,
|
||||
rc = mctp_route_nlparse(net, nlh, extack, tb,
|
||||
&rtm, &mdev, &daddr_start);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
|
@ -1371,7 +1370,7 @@ static int mctp_newroute(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|||
mtu = nla_get_u32(tbx[RTAX_MTU]);
|
||||
}
|
||||
|
||||
rc = mctp_route_add(mdev, daddr_start, rtm->rtm_dst_len, mtu,
|
||||
rc = mctp_route_add(net, mdev, daddr_start, rtm->rtm_dst_len, mtu,
|
||||
rtm->rtm_type);
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -1379,13 +1378,14 @@ static int mctp_newroute(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|||
static int mctp_delroute(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct net *net = sock_net(skb->sk);
|
||||
struct nlattr *tb[RTA_MAX + 1];
|
||||
mctp_eid_t daddr_start;
|
||||
struct mctp_dev *mdev;
|
||||
struct rtmsg *rtm;
|
||||
int rc;
|
||||
|
||||
rc = mctp_route_nlparse(skb, nlh, extack, tb,
|
||||
rc = mctp_route_nlparse(net, nlh, extack, tb,
|
||||
&rtm, &mdev, &daddr_start);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
|
@ -1394,7 +1394,8 @@ static int mctp_delroute(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|||
if (rtm->rtm_type != RTN_UNICAST)
|
||||
return -EINVAL;
|
||||
|
||||
rc = mctp_route_remove(mdev, daddr_start, rtm->rtm_dst_len, RTN_UNICAST);
|
||||
rc = mctp_route_remove(net, mdev, daddr_start, rtm->rtm_dst_len,
|
||||
RTN_UNICAST);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user