Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92a395e5 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller
Browse files

ipmr: Do not use RTA_PUT() macros



Also fix a needless skb tailroom check for a 4 bytes area
after after each rtnexthop block.

Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6e277ed5
Loading
Loading
Loading
Loading
+14 −14
Original line number Original line Diff line number Diff line
@@ -2006,37 +2006,37 @@ static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb,
{
{
	int ct;
	int ct;
	struct rtnexthop *nhp;
	struct rtnexthop *nhp;
	u8 *b = skb_tail_pointer(skb);
	struct nlattr *mp_attr;
	struct rtattr *mp_head;


	/* If cache is unresolved, don't try to parse IIF and OIF */
	/* If cache is unresolved, don't try to parse IIF and OIF */
	if (c->mfc_parent >= MAXVIFS)
	if (c->mfc_parent >= MAXVIFS)
		return -ENOENT;
		return -ENOENT;


	if (VIF_EXISTS(mrt, c->mfc_parent))
	if (VIF_EXISTS(mrt, c->mfc_parent) &&
		RTA_PUT(skb, RTA_IIF, 4, &mrt->vif_table[c->mfc_parent].dev->ifindex);
	    nla_put_u32(skb, RTA_IIF, mrt->vif_table[c->mfc_parent].dev->ifindex) < 0)
		return -EMSGSIZE;


	mp_head = (struct rtattr *)skb_put(skb, RTA_LENGTH(0));
	if (!(mp_attr = nla_nest_start(skb, RTA_MULTIPATH)))
		return -EMSGSIZE;


	for (ct = c->mfc_un.res.minvif; ct < c->mfc_un.res.maxvif; ct++) {
	for (ct = c->mfc_un.res.minvif; ct < c->mfc_un.res.maxvif; ct++) {
		if (VIF_EXISTS(mrt, ct) && c->mfc_un.res.ttls[ct] < 255) {
		if (VIF_EXISTS(mrt, ct) && c->mfc_un.res.ttls[ct] < 255) {
			if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4))
			if (!(nhp = nla_reserve_nohdr(skb, sizeof(*nhp)))) {
				goto rtattr_failure;
				nla_nest_cancel(skb, mp_attr);
			nhp = (struct rtnexthop *)skb_put(skb, RTA_ALIGN(sizeof(*nhp)));
				return -EMSGSIZE;
			}

			nhp->rtnh_flags = 0;
			nhp->rtnh_flags = 0;
			nhp->rtnh_hops = c->mfc_un.res.ttls[ct];
			nhp->rtnh_hops = c->mfc_un.res.ttls[ct];
			nhp->rtnh_ifindex = mrt->vif_table[ct].dev->ifindex;
			nhp->rtnh_ifindex = mrt->vif_table[ct].dev->ifindex;
			nhp->rtnh_len = sizeof(*nhp);
			nhp->rtnh_len = sizeof(*nhp);
		}
		}
	}
	}
	mp_head->rta_type = RTA_MULTIPATH;

	mp_head->rta_len = skb_tail_pointer(skb) - (u8 *)mp_head;
	nla_nest_end(skb, mp_attr);

	rtm->rtm_type = RTN_MULTICAST;
	rtm->rtm_type = RTN_MULTICAST;
	return 1;
	return 1;

rtattr_failure:
	nlmsg_trim(skb, b);
	return -EMSGSIZE;
}
}


int ipmr_get_route(struct net *net, struct sk_buff *skb,
int ipmr_get_route(struct net *net, struct sk_buff *skb,