Skip to content

Commit 6051e2f

Browse files
tgrafDavid S. Miller
authored andcommitted
[IPv6] prefix: Convert RTM_NEWPREFIX notifications to use the new netlink api
RTM_GETPREFIX is completely unused and is thus removed. Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 04561c1 commit 6051e2f

4 files changed

Lines changed: 14 additions & 20 deletions

File tree

‎include/linux/rtnetlink.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ enum {
8181

8282
RTM_NEWPREFIX = 52,
8383
#define RTM_NEWPREFIX RTM_NEWPREFIX
84-
RTM_GETPREFIX = 54,
85-
#define RTM_GETPREFIX RTM_GETPREFIX
8684

8785
RTM_GETMULTICAST = 58,
8886
#define RTM_GETMULTICAST RTM_GETMULTICAST

‎net/core/rtnetlink.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ static const int rtm_min[RTM_NR_FAMILIES] =
108108
[RTM_FAM(RTM_NEWTCLASS)] = NLMSG_LENGTH(sizeof(struct tcmsg)),
109109
[RTM_FAM(RTM_NEWTFILTER)] = NLMSG_LENGTH(sizeof(struct tcmsg)),
110110
[RTM_FAM(RTM_NEWACTION)] = NLMSG_LENGTH(sizeof(struct tcamsg)),
111-
[RTM_FAM(RTM_NEWPREFIX)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
112111
[RTM_FAM(RTM_GETMULTICAST)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
113112
[RTM_FAM(RTM_GETANYCAST)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
114113
};

‎net/ipv6/addrconf.c‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3518,43 +3518,41 @@ static inline size_t inet6_prefix_nlmsg_size(void)
35183518
}
35193519

35203520
static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev,
3521-
struct prefix_info *pinfo, u32 pid, u32 seq,
3522-
int event, unsigned int flags)
3521+
struct prefix_info *pinfo, u32 pid, u32 seq,
3522+
int event, unsigned int flags)
35233523
{
3524-
struct prefixmsg *pmsg;
3525-
struct nlmsghdr *nlh;
3526-
unsigned char *b = skb->tail;
3524+
struct prefixmsg *pmsg;
3525+
struct nlmsghdr *nlh;
35273526
struct prefix_cacheinfo ci;
35283527

3529-
nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*pmsg), flags);
3530-
pmsg = NLMSG_DATA(nlh);
3528+
nlh = nlmsg_put(skb, pid, seq, event, sizeof(*pmsg), flags);
3529+
if (nlh == NULL)
3530+
return -ENOBUFS;
3531+
3532+
pmsg = nlmsg_data(nlh);
35313533
pmsg->prefix_family = AF_INET6;
35323534
pmsg->prefix_pad1 = 0;
35333535
pmsg->prefix_pad2 = 0;
35343536
pmsg->prefix_ifindex = idev->dev->ifindex;
35353537
pmsg->prefix_len = pinfo->prefix_len;
35363538
pmsg->prefix_type = pinfo->type;
35373539
pmsg->prefix_pad3 = 0;
3538-
35393540
pmsg->prefix_flags = 0;
35403541
if (pinfo->onlink)
35413542
pmsg->prefix_flags |= IF_PREFIX_ONLINK;
35423543
if (pinfo->autoconf)
35433544
pmsg->prefix_flags |= IF_PREFIX_AUTOCONF;
35443545

3545-
RTA_PUT(skb, PREFIX_ADDRESS, sizeof(pinfo->prefix), &pinfo->prefix);
3546+
NLA_PUT(skb, PREFIX_ADDRESS, sizeof(pinfo->prefix), &pinfo->prefix);
35463547

35473548
ci.preferred_time = ntohl(pinfo->prefered);
35483549
ci.valid_time = ntohl(pinfo->valid);
3549-
RTA_PUT(skb, PREFIX_CACHEINFO, sizeof(ci), &ci);
3550+
NLA_PUT(skb, PREFIX_CACHEINFO, sizeof(ci), &ci);
35503551

3551-
nlh->nlmsg_len = skb->tail - b;
3552-
return skb->len;
3552+
return nlmsg_end(skb, nlh);
35533553

3554-
nlmsg_failure:
3555-
rtattr_failure:
3556-
skb_trim(skb, b - skb->data);
3557-
return -1;
3554+
nla_put_failure:
3555+
return nlmsg_cancel(skb, nlh);
35583556
}
35593557

35603558
static void inet6_prefix_notify(int event, struct inet6_dev *idev,

‎security/selinux/nlmsgtab.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ static struct nlmsg_perm nlmsg_route_perms[] =
6060
{ RTM_DELACTION, NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
6161
{ RTM_GETACTION, NETLINK_ROUTE_SOCKET__NLMSG_READ },
6262
{ RTM_NEWPREFIX, NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
63-
{ RTM_GETPREFIX, NETLINK_ROUTE_SOCKET__NLMSG_READ },
6463
{ RTM_GETMULTICAST, NETLINK_ROUTE_SOCKET__NLMSG_READ },
6564
{ RTM_GETANYCAST, NETLINK_ROUTE_SOCKET__NLMSG_READ },
6665
{ RTM_GETNEIGHTBL, NETLINK_ROUTE_SOCKET__NLMSG_READ },

0 commit comments

Comments
 (0)