All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Kerr <jk@codeconstruct.com.au>
To: netdev@vger.kernel.org
Cc: Matt Johnston <matt@codeconstruct.com.au>,
	Andrew Jeffery <andrew@aj.id.au>
Subject: [PATCH RFC net-next v2 12/16] mctp: Add dest neighbour lladdr to route output
Date: Tue, 13 Jul 2021 14:20:19 +0800	[thread overview]
Message-ID: <20210713062023.3286895-13-jk@codeconstruct.com.au> (raw)
In-Reply-To: <20210713062023.3286895-1-jk@codeconstruct.com.au>

From: Matt Johnston <matt@codeconstruct.com.au>

Now that we have a neighbour implementation, hook it up to the output
path to set the dest hardware address for outgoing packets.

Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
---
 net/mctp/route.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/mctp/route.c b/net/mctp/route.c
index 1909437f9a15..cf06d88ca0ca 100644
--- a/net/mctp/route.c
+++ b/net/mctp/route.c
@@ -169,6 +169,9 @@ static int mctp_route_input(struct mctp_route *route, struct sk_buff *skb)
 
 static int mctp_route_output(struct mctp_route *route, struct sk_buff *skb)
 {
+	struct mctp_hdr *hdr = mctp_hdr(skb);
+	char daddr_buf[MAX_ADDR_LEN];
+	char *daddr = NULL;
 	unsigned int mtu;
 	int rc;
 
@@ -180,9 +183,12 @@ static int mctp_route_output(struct mctp_route *route, struct sk_buff *skb)
 		return -EMSGSIZE;
 	}
 
-	/* TODO: daddr (from rt->neigh), saddr (from device?)  */
+	/* If lookup fails let the device handle daddr==NULL */
+	if (mctp_neigh_lookup(route->dev, hdr->dest, daddr_buf) == 0)
+		daddr = daddr_buf;
+
 	rc = dev_hard_header(skb, skb->dev, ntohs(skb->protocol),
-			     NULL, NULL, skb->len);
+			     daddr, skb->dev->dev_addr, skb->len);
 	if (rc) {
 		kfree_skb(skb);
 		return -EHOSTUNREACH;
-- 
2.30.2


  parent reply	other threads:[~2021-07-13  6:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13  6:20 [PATCH RFC net-next v2 00/16] Add Management Component Transport Protocol support Jeremy Kerr
2021-07-13  6:20 ` [PATCH RFC net-next v2 01/16] mctp: Add MCTP base Jeremy Kerr
2021-07-13  6:20 ` [PATCH RFC net-next v2 02/16] mctp: Add base socket/protocol definitions Jeremy Kerr
2021-07-13  6:20 ` [PATCH RFC net-next v2 03/16] mctp: Add base packet definitions Jeremy Kerr
2021-07-13  6:20 ` [PATCH RFC net-next v2 04/16] mctp: Add sockaddr_mctp to uapi Jeremy Kerr
2021-07-13  6:20 ` [PATCH RFC net-next v2 05/16] mctp: Add initial driver infrastructure Jeremy Kerr
2021-07-13  6:20 ` [PATCH RFC net-next v2 06/16] mctp: Add device handling and netlink interface Jeremy Kerr
2021-07-13  6:20 ` [PATCH RFC net-next v2 07/16] mctp: Add initial routing framework Jeremy Kerr
2021-07-13  6:20 ` [PATCH RFC net-next v2 08/16] mctp: Add netlink route management Jeremy Kerr
2021-07-13  6:20 ` [PATCH RFC net-next v2 09/16] mctp: Add neighbour implementation Jeremy Kerr
2021-07-13  6:20 ` [PATCH RFC net-next v2 10/16] mctp: Add neighbour netlink interface Jeremy Kerr
2021-07-13  6:20 ` [PATCH RFC net-next v2 11/16] mctp: Populate socket implementation Jeremy Kerr
2021-07-13  6:20 ` Jeremy Kerr [this message]
2021-07-13  6:20 ` [PATCH RFC net-next v2 13/16] mctp: Implement message fragmentation & reassembly Jeremy Kerr
2021-07-13  6:20 ` [PATCH RFC net-next v2 14/16] mctp: Allow per-netns default networks Jeremy Kerr
2021-07-13  6:20 ` [PATCH RFC net-next v2 15/16] mctp: Allow MCTP on tun devices Jeremy Kerr
2021-07-13  6:20 ` [PATCH RFC net-next v2 16/16] mctp: Add MCTP overview document Jeremy Kerr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210713062023.3286895-13-jk@codeconstruct.com.au \
    --to=jk@codeconstruct.com.au \
    --cc=andrew@aj.id.au \
    --cc=matt@codeconstruct.com.au \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.