mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 07:03:03 +02:00
Merge branch 'adopting-nlmsg_payload-in-ipv4-ipv6'
Breno Leitao says:
====================
Adopting nlmsg_payload() in IPv4/IPv6
The commit 95d06e92a4 ("netlink: Introduce nlmsg_payload helper")
introduced the nlmsg_payload() helper function.
This patchset aims to replace manual implementations with the
nlmsg_payload() helper in IPv4 and IPv6 files, one file per patch.
====================
Link: https://patch.msgid.link/20250415-nlmsg_v2-v1-0-a1c75d493fd7@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
522b93f61f
|
|
@ -411,13 +411,12 @@ static int vxlan_vnifilter_dump(struct sk_buff *skb, struct netlink_callback *cb
|
|||
struct tunnel_msg *tmsg;
|
||||
struct net_device *dev;
|
||||
|
||||
if (cb->nlh->nlmsg_len < nlmsg_msg_size(sizeof(struct tunnel_msg))) {
|
||||
tmsg = nlmsg_payload(cb->nlh, sizeof(*tmsg));
|
||||
if (!tmsg) {
|
||||
NL_SET_ERR_MSG(cb->extack, "Invalid msg length");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
tmsg = nlmsg_data(cb->nlh);
|
||||
|
||||
if (tmsg->flags & ~TUNNEL_MSG_VALID_USER_FLAGS) {
|
||||
NL_SET_ERR_MSG(cb->extack, "Invalid tunnelmsg flags in ancillary header");
|
||||
return -EINVAL;
|
||||
|
|
|
|||
|
|
@ -1792,12 +1792,12 @@ static int inet_valid_dump_ifaddr_req(const struct nlmsghdr *nlh,
|
|||
struct ifaddrmsg *ifm;
|
||||
int err, i;
|
||||
|
||||
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) {
|
||||
ifm = nlmsg_payload(nlh, sizeof(*ifm));
|
||||
if (!ifm) {
|
||||
NL_SET_ERR_MSG(extack, "ipv4: Invalid header for address dump request");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ifm = nlmsg_data(nlh);
|
||||
if (ifm->ifa_prefixlen || ifm->ifa_flags || ifm->ifa_scope) {
|
||||
NL_SET_ERR_MSG(extack, "ipv4: Invalid values in header for address dump request");
|
||||
return -EINVAL;
|
||||
|
|
|
|||
|
|
@ -948,12 +948,12 @@ int ip_valid_fib_dump_req(struct net *net, const struct nlmsghdr *nlh,
|
|||
if (filter->rtnl_held)
|
||||
ASSERT_RTNL();
|
||||
|
||||
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*rtm))) {
|
||||
rtm = nlmsg_payload(nlh, sizeof(*rtm));
|
||||
if (!rtm) {
|
||||
NL_SET_ERR_MSG(extack, "Invalid header for FIB dump request");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
rtm = nlmsg_data(nlh);
|
||||
if (rtm->rtm_dst_len || rtm->rtm_src_len || rtm->rtm_tos ||
|
||||
rtm->rtm_scope) {
|
||||
NL_SET_ERR_MSG(extack, "Invalid values in header for FIB dump request");
|
||||
|
|
|
|||
|
|
@ -2511,7 +2511,8 @@ static int ipmr_rtm_valid_getroute_req(struct sk_buff *skb,
|
|||
struct rtmsg *rtm;
|
||||
int i, err;
|
||||
|
||||
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*rtm))) {
|
||||
rtm = nlmsg_payload(nlh, sizeof(*rtm));
|
||||
if (!rtm) {
|
||||
NL_SET_ERR_MSG(extack, "ipv4: Invalid header for multicast route get request");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -2520,7 +2521,6 @@ static int ipmr_rtm_valid_getroute_req(struct sk_buff *skb,
|
|||
return nlmsg_parse_deprecated(nlh, sizeof(*rtm), tb, RTA_MAX,
|
||||
rtm_ipv4_policy, extack);
|
||||
|
||||
rtm = nlmsg_data(nlh);
|
||||
if ((rtm->rtm_src_len && rtm->rtm_src_len != 32) ||
|
||||
(rtm->rtm_dst_len && rtm->rtm_dst_len != 32) ||
|
||||
rtm->rtm_tos || rtm->rtm_table || rtm->rtm_protocol ||
|
||||
|
|
@ -2836,7 +2836,8 @@ static int ipmr_valid_dumplink(const struct nlmsghdr *nlh,
|
|||
{
|
||||
struct ifinfomsg *ifm;
|
||||
|
||||
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) {
|
||||
ifm = nlmsg_payload(nlh, sizeof(*ifm));
|
||||
if (!ifm) {
|
||||
NL_SET_ERR_MSG(extack, "ipv4: Invalid header for ipmr link dump");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -2846,7 +2847,6 @@ static int ipmr_valid_dumplink(const struct nlmsghdr *nlh,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
ifm = nlmsg_data(nlh);
|
||||
if (ifm->__ifi_pad || ifm->ifi_type || ifm->ifi_flags ||
|
||||
ifm->ifi_change || ifm->ifi_index) {
|
||||
NL_SET_ERR_MSG(extack, "Invalid values in header for ipmr link dump request");
|
||||
|
|
|
|||
|
|
@ -3205,7 +3205,8 @@ static int inet_rtm_valid_getroute_req(struct sk_buff *skb,
|
|||
struct rtmsg *rtm;
|
||||
int i, err;
|
||||
|
||||
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*rtm))) {
|
||||
rtm = nlmsg_payload(nlh, sizeof(*rtm));
|
||||
if (!rtm) {
|
||||
NL_SET_ERR_MSG(extack,
|
||||
"ipv4: Invalid header for route get request");
|
||||
return -EINVAL;
|
||||
|
|
@ -3215,7 +3216,6 @@ static int inet_rtm_valid_getroute_req(struct sk_buff *skb,
|
|||
return nlmsg_parse_deprecated(nlh, sizeof(*rtm), tb, RTA_MAX,
|
||||
rtm_ipv4_policy, extack);
|
||||
|
||||
rtm = nlmsg_data(nlh);
|
||||
if ((rtm->rtm_src_len && rtm->rtm_src_len != 32) ||
|
||||
(rtm->rtm_dst_len && rtm->rtm_dst_len != 32) ||
|
||||
rtm->rtm_table || rtm->rtm_protocol ||
|
||||
|
|
|
|||
|
|
@ -6112,7 +6112,8 @@ static int inet6_valid_dump_ifinfo(const struct nlmsghdr *nlh,
|
|||
{
|
||||
struct ifinfomsg *ifm;
|
||||
|
||||
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) {
|
||||
ifm = nlmsg_payload(nlh, sizeof(*ifm));
|
||||
if (!ifm) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Invalid header for link dump request");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -6122,7 +6123,6 @@ static int inet6_valid_dump_ifinfo(const struct nlmsghdr *nlh,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
ifm = nlmsg_data(nlh);
|
||||
if (ifm->__ifi_pad || ifm->ifi_type || ifm->ifi_flags ||
|
||||
ifm->ifi_change || ifm->ifi_index) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for dump request");
|
||||
|
|
|
|||
|
|
@ -473,12 +473,12 @@ static int ip6addrlbl_valid_dump_req(const struct nlmsghdr *nlh,
|
|||
{
|
||||
struct ifaddrlblmsg *ifal;
|
||||
|
||||
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifal))) {
|
||||
ifal = nlmsg_payload(nlh, sizeof(*ifal));
|
||||
if (!ifal) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Invalid header for address label dump request");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ifal = nlmsg_data(nlh);
|
||||
if (ifal->__ifal_reserved || ifal->ifal_prefixlen ||
|
||||
ifal->ifal_flags || ifal->ifal_index || ifal->ifal_seq) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for address label dump request");
|
||||
|
|
@ -543,7 +543,8 @@ static int ip6addrlbl_valid_get_req(struct sk_buff *skb,
|
|||
struct ifaddrlblmsg *ifal;
|
||||
int i, err;
|
||||
|
||||
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifal))) {
|
||||
ifal = nlmsg_payload(nlh, sizeof(*ifal));
|
||||
if (!ifal) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Invalid header for addrlabel get request");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -552,7 +553,6 @@ static int ip6addrlbl_valid_get_req(struct sk_buff *skb,
|
|||
return nlmsg_parse_deprecated(nlh, sizeof(*ifal), tb,
|
||||
IFAL_MAX, ifal_policy, extack);
|
||||
|
||||
ifal = nlmsg_data(nlh);
|
||||
if (ifal->__ifal_reserved || ifal->ifal_flags || ifal->ifal_seq) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for addrlabel get request");
|
||||
return -EINVAL;
|
||||
|
|
|
|||
|
|
@ -6029,7 +6029,8 @@ static int inet6_rtm_valid_getroute_req(struct sk_buff *skb,
|
|||
struct rtmsg *rtm;
|
||||
int i, err;
|
||||
|
||||
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*rtm))) {
|
||||
rtm = nlmsg_payload(nlh, sizeof(*rtm));
|
||||
if (!rtm) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"Invalid header for get route request");
|
||||
return -EINVAL;
|
||||
|
|
@ -6039,7 +6040,6 @@ static int inet6_rtm_valid_getroute_req(struct sk_buff *skb,
|
|||
return nlmsg_parse_deprecated(nlh, sizeof(*rtm), tb, RTA_MAX,
|
||||
rtm_ipv6_policy, extack);
|
||||
|
||||
rtm = nlmsg_data(nlh);
|
||||
if ((rtm->rtm_src_len && rtm->rtm_src_len != 128) ||
|
||||
(rtm->rtm_dst_len && rtm->rtm_dst_len != 128) ||
|
||||
rtm->rtm_table || rtm->rtm_protocol || rtm->rtm_scope ||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user