Commit 1c2bc7b9 authored by David Howells's avatar David Howells

rxrpc: Use rxrpc_extract_addr_from_skb() rather than doing this manually

There are two places that want to transmit a packet in response to one just
received and manually pick the address to reply to out of the sk_buff.
Make them use rxrpc_extract_addr_from_skb() instead so that IPv6 is handled
automatically.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
parent aaa31cbc
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
#include <linux/net.h> #include <linux/net.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/udp.h>
#include <linux/ip.h>
#include <net/sock.h> #include <net/sock.h>
#include <net/af_rxrpc.h> #include <net/af_rxrpc.h>
#include <generated/utsrelease.h> #include <generated/utsrelease.h>
...@@ -33,7 +31,7 @@ static void rxrpc_send_version_request(struct rxrpc_local *local, ...@@ -33,7 +31,7 @@ static void rxrpc_send_version_request(struct rxrpc_local *local,
{ {
struct rxrpc_wire_header whdr; struct rxrpc_wire_header whdr;
struct rxrpc_skb_priv *sp = rxrpc_skb(skb); struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
struct sockaddr_in sin; struct sockaddr_rxrpc srx;
struct msghdr msg; struct msghdr msg;
struct kvec iov[2]; struct kvec iov[2];
size_t len; size_t len;
...@@ -41,12 +39,11 @@ static void rxrpc_send_version_request(struct rxrpc_local *local, ...@@ -41,12 +39,11 @@ static void rxrpc_send_version_request(struct rxrpc_local *local,
_enter(""); _enter("");
sin.sin_family = AF_INET; if (rxrpc_extract_addr_from_skb(&srx, skb) < 0)
sin.sin_port = udp_hdr(skb)->source; return;
sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
msg.msg_name = &sin; msg.msg_name = &srx.transport;
msg.msg_namelen = sizeof(sin); msg.msg_namelen = srx.transport_len;
msg.msg_control = NULL; msg.msg_control = NULL;
msg.msg_controllen = 0; msg.msg_controllen = 0;
msg.msg_flags = 0; msg.msg_flags = 0;
......
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
#include <linux/gfp.h> #include <linux/gfp.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/udp.h>
#include <linux/ip.h>
#include <net/sock.h> #include <net/sock.h>
#include <net/af_rxrpc.h> #include <net/af_rxrpc.h>
#include "ar-internal.h" #include "ar-internal.h"
...@@ -272,10 +270,7 @@ int rxrpc_send_data_packet(struct rxrpc_connection *conn, struct sk_buff *skb) ...@@ -272,10 +270,7 @@ int rxrpc_send_data_packet(struct rxrpc_connection *conn, struct sk_buff *skb)
*/ */
void rxrpc_reject_packets(struct rxrpc_local *local) void rxrpc_reject_packets(struct rxrpc_local *local)
{ {
union { struct sockaddr_rxrpc srx;
struct sockaddr sa;
struct sockaddr_in sin;
} sa;
struct rxrpc_skb_priv *sp; struct rxrpc_skb_priv *sp;
struct rxrpc_wire_header whdr; struct rxrpc_wire_header whdr;
struct sk_buff *skb; struct sk_buff *skb;
...@@ -292,32 +287,21 @@ void rxrpc_reject_packets(struct rxrpc_local *local) ...@@ -292,32 +287,21 @@ void rxrpc_reject_packets(struct rxrpc_local *local)
iov[1].iov_len = sizeof(code); iov[1].iov_len = sizeof(code);
size = sizeof(whdr) + sizeof(code); size = sizeof(whdr) + sizeof(code);
msg.msg_name = &sa; msg.msg_name = &srx.transport;
msg.msg_control = NULL; msg.msg_control = NULL;
msg.msg_controllen = 0; msg.msg_controllen = 0;
msg.msg_flags = 0; msg.msg_flags = 0;
memset(&sa, 0, sizeof(sa));
sa.sa.sa_family = local->srx.transport.family;
switch (sa.sa.sa_family) {
case AF_INET:
msg.msg_namelen = sizeof(sa.sin);
break;
default:
msg.msg_namelen = 0;
break;
}
memset(&whdr, 0, sizeof(whdr)); memset(&whdr, 0, sizeof(whdr));
whdr.type = RXRPC_PACKET_TYPE_ABORT; whdr.type = RXRPC_PACKET_TYPE_ABORT;
while ((skb = skb_dequeue(&local->reject_queue))) { while ((skb = skb_dequeue(&local->reject_queue))) {
rxrpc_see_skb(skb); rxrpc_see_skb(skb);
sp = rxrpc_skb(skb); sp = rxrpc_skb(skb);
switch (sa.sa.sa_family) {
case AF_INET: if (rxrpc_extract_addr_from_skb(&srx, skb) == 0) {
sa.sin.sin_port = udp_hdr(skb)->source; msg.msg_namelen = srx.transport_len;
sa.sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
code = htonl(skb->priority); code = htonl(skb->priority);
whdr.epoch = htonl(sp->hdr.epoch); whdr.epoch = htonl(sp->hdr.epoch);
...@@ -329,10 +313,6 @@ void rxrpc_reject_packets(struct rxrpc_local *local) ...@@ -329,10 +313,6 @@ void rxrpc_reject_packets(struct rxrpc_local *local)
whdr.flags &= RXRPC_CLIENT_INITIATED; whdr.flags &= RXRPC_CLIENT_INITIATED;
kernel_sendmsg(local->socket, &msg, iov, 2, size); kernel_sendmsg(local->socket, &msg, iov, 2, size);
break;
default:
break;
} }
rxrpc_free_skb(skb); rxrpc_free_skb(skb);
......
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