Commit d4e72560 authored by David Ahern's avatar David Ahern Committed by David S. Miller

net: mpls: Make nla_get_via in af_mpls.c

nla_get_via is only used in af_mpls.c. Remove declaration from internal.h
and move up in af_mpls.c before first use. Code move only; no
functional change intended.
Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 074350e2
...@@ -684,6 +684,54 @@ static int mpls_nh_assign_dev(struct net *net, struct mpls_route *rt, ...@@ -684,6 +684,54 @@ static int mpls_nh_assign_dev(struct net *net, struct mpls_route *rt,
return err; return err;
} }
static int nla_get_via(const struct nlattr *nla, u8 *via_alen, u8 *via_table,
u8 via_addr[], struct netlink_ext_ack *extack)
{
struct rtvia *via = nla_data(nla);
int err = -EINVAL;
int alen;
if (nla_len(nla) < offsetof(struct rtvia, rtvia_addr)) {
NL_SET_ERR_MSG_ATTR(extack, nla,
"Invalid attribute length for RTA_VIA");
goto errout;
}
alen = nla_len(nla) -
offsetof(struct rtvia, rtvia_addr);
if (alen > MAX_VIA_ALEN) {
NL_SET_ERR_MSG_ATTR(extack, nla,
"Invalid address length for RTA_VIA");
goto errout;
}
/* Validate the address family */
switch (via->rtvia_family) {
case AF_PACKET:
*via_table = NEIGH_LINK_TABLE;
break;
case AF_INET:
*via_table = NEIGH_ARP_TABLE;
if (alen != 4)
goto errout;
break;
case AF_INET6:
*via_table = NEIGH_ND_TABLE;
if (alen != 16)
goto errout;
break;
default:
/* Unsupported address family */
goto errout;
}
memcpy(via_addr, via->rtvia_addr, alen);
*via_alen = alen;
err = 0;
errout:
return err;
}
static int mpls_nh_build_from_cfg(struct mpls_route_config *cfg, static int mpls_nh_build_from_cfg(struct mpls_route_config *cfg,
struct mpls_route *rt) struct mpls_route *rt)
{ {
...@@ -1641,54 +1689,6 @@ int nla_get_labels(const struct nlattr *nla, u8 max_labels, u8 *labels, ...@@ -1641,54 +1689,6 @@ int nla_get_labels(const struct nlattr *nla, u8 max_labels, u8 *labels,
} }
EXPORT_SYMBOL_GPL(nla_get_labels); EXPORT_SYMBOL_GPL(nla_get_labels);
int nla_get_via(const struct nlattr *nla, u8 *via_alen, u8 *via_table,
u8 via_addr[], struct netlink_ext_ack *extack)
{
struct rtvia *via = nla_data(nla);
int err = -EINVAL;
int alen;
if (nla_len(nla) < offsetof(struct rtvia, rtvia_addr)) {
NL_SET_ERR_MSG_ATTR(extack, nla,
"Invalid attribute length for RTA_VIA");
goto errout;
}
alen = nla_len(nla) -
offsetof(struct rtvia, rtvia_addr);
if (alen > MAX_VIA_ALEN) {
NL_SET_ERR_MSG_ATTR(extack, nla,
"Invalid address length for RTA_VIA");
goto errout;
}
/* Validate the address family */
switch (via->rtvia_family) {
case AF_PACKET:
*via_table = NEIGH_LINK_TABLE;
break;
case AF_INET:
*via_table = NEIGH_ARP_TABLE;
if (alen != 4)
goto errout;
break;
case AF_INET6:
*via_table = NEIGH_ND_TABLE;
if (alen != 16)
goto errout;
break;
default:
/* Unsupported address family */
goto errout;
}
memcpy(via_addr, via->rtvia_addr, alen);
*via_alen = alen;
err = 0;
errout:
return err;
}
static int rtm_to_route_config(struct sk_buff *skb, static int rtm_to_route_config(struct sk_buff *skb,
struct nlmsghdr *nlh, struct nlmsghdr *nlh,
struct mpls_route_config *cfg, struct mpls_route_config *cfg,
......
...@@ -204,8 +204,6 @@ int nla_put_labels(struct sk_buff *skb, int attrtype, u8 labels, ...@@ -204,8 +204,6 @@ int nla_put_labels(struct sk_buff *skb, int attrtype, u8 labels,
const u32 label[]); const u32 label[]);
int nla_get_labels(const struct nlattr *nla, u8 max_labels, u8 *labels, int nla_get_labels(const struct nlattr *nla, u8 max_labels, u8 *labels,
u32 label[], struct netlink_ext_ack *extack); u32 label[], struct netlink_ext_ack *extack);
int nla_get_via(const struct nlattr *nla, u8 *via_alen, u8 *via_table,
u8 via[], struct netlink_ext_ack *extack);
bool mpls_output_possible(const struct net_device *dev); bool mpls_output_possible(const struct net_device *dev);
unsigned int mpls_dev_mtu(const struct net_device *dev); unsigned int mpls_dev_mtu(const struct net_device *dev);
bool mpls_pkt_too_big(const struct sk_buff *skb, unsigned int mtu); bool mpls_pkt_too_big(const struct sk_buff *skb, unsigned int mtu);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment