summaryrefslogtreecommitdiffstats
path: root/net/rxrpc/ar-internal.h
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2016-03-04 10:53:46 -0500
committerDavid Howells <dhowells@redhat.com>2016-03-04 10:53:46 -0500
commit0d12f8a4027d021c9cc942f09f38d28288020c5d (patch)
tree751f54f93f15d9c0146cf2e4243dbfc25fd1cc6d /net/rxrpc/ar-internal.h
parent4c198ad17a7253cc8ef3ff39bfe73d6b5e65ceef (diff)
rxrpc: Keep the skb private record of the Rx header in host byte order
Currently, a copy of the Rx packet header is copied into the the sk_buff private data so that we can advance the pointer into the buffer, potentially discarding the original. At the moment, this copy is held in network byte order, but this means we're doing a lot of unnecessary translations. The reasons it was done this way are that we need the values in network byte order occasionally and we can use the copy, slightly modified, as part of an iov array when sending an ack or an abort packet. However, it seems more reasonable on review that it would be better kept in host byte order and that we make up a new header when we want to send another packet. To this end, rename the original header struct to rxrpc_wire_header (with BE fields) and institute a variant called rxrpc_host_header that has host order fields. Change the struct in the sk_buff private data into an rxrpc_host_header and translate the values when filling it in. This further allows us to keep values kept in various structures in host byte order rather than network byte order and allows removal of some fields that are byteswapped duplicates. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'net/rxrpc/ar-internal.h')
-rw-r--r--net/rxrpc/ar-internal.h65
1 files changed, 40 insertions, 25 deletions
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index 3f2940626569..06bf5abd920d 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -70,12 +70,31 @@ struct rxrpc_sock {
70#define RXRPC_SECURITY_MAX RXRPC_SECURITY_ENCRYPT 70#define RXRPC_SECURITY_MAX RXRPC_SECURITY_ENCRYPT
71 struct sockaddr_rxrpc srx; /* local address */ 71 struct sockaddr_rxrpc srx; /* local address */
72 sa_family_t proto; /* protocol created with */ 72 sa_family_t proto; /* protocol created with */
73 __be16 service_id; /* service ID of local/remote service */
74}; 73};
75 74
76#define rxrpc_sk(__sk) container_of((__sk), struct rxrpc_sock, sk) 75#define rxrpc_sk(__sk) container_of((__sk), struct rxrpc_sock, sk)
77 76
78/* 77/*
78 * CPU-byteorder normalised Rx packet header.
79 */
80struct rxrpc_host_header {
81 u32 epoch; /* client boot timestamp */
82 u32 cid; /* connection and channel ID */
83 u32 callNumber; /* call ID (0 for connection-level packets) */
84 u32 seq; /* sequence number of pkt in call stream */
85 u32 serial; /* serial number of pkt sent to network */
86 u8 type; /* packet type */
87 u8 flags; /* packet flags */
88 u8 userStatus; /* app-layer defined status */
89 u8 securityIndex; /* security protocol ID */
90 union {
91 u16 _rsvd; /* reserved */
92 u16 cksum; /* kerberos security checksum */
93 };
94 u16 serviceId; /* service ID */
95} __packed;
96
97/*
79 * RxRPC socket buffer private variables 98 * RxRPC socket buffer private variables
80 * - max 48 bytes (struct sk_buff::cb) 99 * - max 48 bytes (struct sk_buff::cb)
81 */ 100 */
@@ -89,7 +108,7 @@ struct rxrpc_skb_priv {
89 bool need_resend; /* T if needs resending */ 108 bool need_resend; /* T if needs resending */
90 }; 109 };
91 110
92 struct rxrpc_header hdr; /* RxRPC packet header from this packet */ 111 struct rxrpc_host_header hdr; /* RxRPC packet header from this packet */
93}; 112};
94 113
95#define rxrpc_skb(__skb) ((struct rxrpc_skb_priv *) &(__skb)->cb) 114#define rxrpc_skb(__skb) ((struct rxrpc_skb_priv *) &(__skb)->cb)
@@ -230,7 +249,7 @@ struct rxrpc_conn_bundle {
230 atomic_t usage; 249 atomic_t usage;
231 int debug_id; /* debug ID for printks */ 250 int debug_id; /* debug ID for printks */
232 unsigned short num_conns; /* number of connections in this bundle */ 251 unsigned short num_conns; /* number of connections in this bundle */
233 __be16 service_id; /* service ID */ 252 u16 service_id; /* Service ID for this bundle */
234 u8 security_ix; /* security type */ 253 u8 security_ix; /* security type */
235}; 254};
236 255
@@ -260,7 +279,6 @@ struct rxrpc_connection {
260 rwlock_t lock; /* access lock */ 279 rwlock_t lock; /* access lock */
261 spinlock_t state_lock; /* state-change lock */ 280 spinlock_t state_lock; /* state-change lock */
262 atomic_t usage; 281 atomic_t usage;
263 u32 real_conn_id; /* connection ID (host-endian) */
264 enum { /* current state of connection */ 282 enum { /* current state of connection */
265 RXRPC_CONN_UNUSED, /* - connection not yet attempted */ 283 RXRPC_CONN_UNUSED, /* - connection not yet attempted */
266 RXRPC_CONN_CLIENT, /* - client connection */ 284 RXRPC_CONN_CLIENT, /* - client connection */
@@ -282,11 +300,9 @@ struct rxrpc_connection {
282 u8 security_size; /* security header size */ 300 u8 security_size; /* security header size */
283 u32 security_level; /* security level negotiated */ 301 u32 security_level; /* security level negotiated */
284 u32 security_nonce; /* response re-use preventer */ 302 u32 security_nonce; /* response re-use preventer */
285 303 u32 epoch; /* epoch of this connection */
286 /* the following are all in net order */ 304 u32 cid; /* connection ID */
287 __be32 epoch; /* epoch of this connection */ 305 u16 service_id; /* service ID for this connection */
288 __be32 cid; /* connection ID */
289 __be16 service_id; /* service ID */
290 u8 security_ix; /* security type */ 306 u8 security_ix; /* security type */
291 u8 in_clientflag; /* RXRPC_CLIENT_INITIATED if we are server */ 307 u8 in_clientflag; /* RXRPC_CLIENT_INITIATED if we are server */
292 u8 out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */ 308 u8 out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */
@@ -406,9 +422,9 @@ struct rxrpc_call {
406 rxrpc_seq_t rx_data_eaten; /* last data seq ID consumed by recvmsg */ 422 rxrpc_seq_t rx_data_eaten; /* last data seq ID consumed by recvmsg */
407 rxrpc_seq_t rx_first_oos; /* first packet in rx_oos_queue (or 0) */ 423 rxrpc_seq_t rx_first_oos; /* first packet in rx_oos_queue (or 0) */
408 rxrpc_seq_t ackr_win_top; /* top of ACK window (rx_data_eaten is bottom) */ 424 rxrpc_seq_t ackr_win_top; /* top of ACK window (rx_data_eaten is bottom) */
409 rxrpc_seq_net_t ackr_prev_seq; /* previous sequence number received */ 425 rxrpc_seq_t ackr_prev_seq; /* previous sequence number received */
410 u8 ackr_reason; /* reason to ACK */ 426 u8 ackr_reason; /* reason to ACK */
411 __be32 ackr_serial; /* serial of packet being ACK'd */ 427 rxrpc_serial_t ackr_serial; /* serial of packet being ACK'd */
412 atomic_t ackr_not_idle; /* number of packets in Rx queue */ 428 atomic_t ackr_not_idle; /* number of packets in Rx queue */
413 429
414 /* received packet records, 1 bit per record */ 430 /* received packet records, 1 bit per record */
@@ -420,11 +436,10 @@ struct rxrpc_call {
420 u8 in_clientflag; /* Copy of conn->in_clientflag for hashing */ 436 u8 in_clientflag; /* Copy of conn->in_clientflag for hashing */
421 struct rxrpc_local *local; /* Local endpoint. Used for hashing. */ 437 struct rxrpc_local *local; /* Local endpoint. Used for hashing. */
422 sa_family_t proto; /* Frame protocol */ 438 sa_family_t proto; /* Frame protocol */
423 /* the following should all be in net order */ 439 u32 call_id; /* call ID on connection */
424 __be32 cid; /* connection ID + channel index */ 440 u32 cid; /* connection ID plus channel index */
425 __be32 call_id; /* call ID on connection */ 441 u32 epoch; /* epoch of this connection */
426 __be32 epoch; /* epoch of this connection */ 442 u16 service_id; /* service ID */
427 __be16 service_id; /* service ID */
428 union { /* Peer IP address for hashing */ 443 union { /* Peer IP address for hashing */
429 __be32 ipv4_addr; 444 __be32 ipv4_addr;
430 __u8 ipv6_addr[16]; /* Anticipates eventual IPv6 support */ 445 __u8 ipv6_addr[16]; /* Anticipates eventual IPv6 support */
@@ -449,7 +464,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
449 * af_rxrpc.c 464 * af_rxrpc.c
450 */ 465 */
451extern atomic_t rxrpc_n_skbs; 466extern atomic_t rxrpc_n_skbs;
452extern __be32 rxrpc_epoch; 467extern u32 rxrpc_epoch;
453extern atomic_t rxrpc_debug_id; 468extern atomic_t rxrpc_debug_id;
454extern struct workqueue_struct *rxrpc_workqueue; 469extern struct workqueue_struct *rxrpc_workqueue;
455 470
@@ -470,8 +485,8 @@ extern unsigned rxrpc_rx_window_size;
470extern unsigned rxrpc_rx_mtu; 485extern unsigned rxrpc_rx_mtu;
471extern unsigned rxrpc_rx_jumbo_max; 486extern unsigned rxrpc_rx_jumbo_max;
472 487
473void __rxrpc_propose_ACK(struct rxrpc_call *, u8, __be32, bool); 488void __rxrpc_propose_ACK(struct rxrpc_call *, u8, u32, bool);
474void rxrpc_propose_ACK(struct rxrpc_call *, u8, __be32, bool); 489void rxrpc_propose_ACK(struct rxrpc_call *, u8, u32, bool);
475void rxrpc_process_call(struct work_struct *); 490void rxrpc_process_call(struct work_struct *);
476 491
477/* 492/*
@@ -483,15 +498,15 @@ extern struct kmem_cache *rxrpc_call_jar;
483extern struct list_head rxrpc_calls; 498extern struct list_head rxrpc_calls;
484extern rwlock_t rxrpc_call_lock; 499extern rwlock_t rxrpc_call_lock;
485 500
486struct rxrpc_call *rxrpc_find_call_hash(u8, __be32, __be32, __be32, 501struct rxrpc_call *rxrpc_find_call_hash(struct rxrpc_host_header *,
487 __be16, void *, sa_family_t, const u8 *); 502 void *, sa_family_t, const void *);
488struct rxrpc_call *rxrpc_get_client_call(struct rxrpc_sock *, 503struct rxrpc_call *rxrpc_get_client_call(struct rxrpc_sock *,
489 struct rxrpc_transport *, 504 struct rxrpc_transport *,
490 struct rxrpc_conn_bundle *, 505 struct rxrpc_conn_bundle *,
491 unsigned long, int, gfp_t); 506 unsigned long, int, gfp_t);
492struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *, 507struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *,
493 struct rxrpc_connection *, 508 struct rxrpc_connection *,
494 struct rxrpc_header *, gfp_t); 509 struct rxrpc_host_header *, gfp_t);
495struct rxrpc_call *rxrpc_find_server_call(struct rxrpc_sock *, unsigned long); 510struct rxrpc_call *rxrpc_find_server_call(struct rxrpc_sock *, unsigned long);
496void rxrpc_release_call(struct rxrpc_call *); 511void rxrpc_release_call(struct rxrpc_call *);
497void rxrpc_release_calls_on_socket(struct rxrpc_sock *); 512void rxrpc_release_calls_on_socket(struct rxrpc_sock *);
@@ -507,16 +522,16 @@ extern rwlock_t rxrpc_connection_lock;
507 522
508struct rxrpc_conn_bundle *rxrpc_get_bundle(struct rxrpc_sock *, 523struct rxrpc_conn_bundle *rxrpc_get_bundle(struct rxrpc_sock *,
509 struct rxrpc_transport *, 524 struct rxrpc_transport *,
510 struct key *, __be16, gfp_t); 525 struct key *, u16, gfp_t);
511void rxrpc_put_bundle(struct rxrpc_transport *, struct rxrpc_conn_bundle *); 526void rxrpc_put_bundle(struct rxrpc_transport *, struct rxrpc_conn_bundle *);
512int rxrpc_connect_call(struct rxrpc_sock *, struct rxrpc_transport *, 527int rxrpc_connect_call(struct rxrpc_sock *, struct rxrpc_transport *,
513 struct rxrpc_conn_bundle *, struct rxrpc_call *, gfp_t); 528 struct rxrpc_conn_bundle *, struct rxrpc_call *, gfp_t);
514void rxrpc_put_connection(struct rxrpc_connection *); 529void rxrpc_put_connection(struct rxrpc_connection *);
515void __exit rxrpc_destroy_all_connections(void); 530void __exit rxrpc_destroy_all_connections(void);
516struct rxrpc_connection *rxrpc_find_connection(struct rxrpc_transport *, 531struct rxrpc_connection *rxrpc_find_connection(struct rxrpc_transport *,
517 struct rxrpc_header *); 532 struct rxrpc_host_header *);
518extern struct rxrpc_connection * 533extern struct rxrpc_connection *
519rxrpc_incoming_connection(struct rxrpc_transport *, struct rxrpc_header *, 534rxrpc_incoming_connection(struct rxrpc_transport *, struct rxrpc_host_header *,
520 gfp_t); 535 gfp_t);
521 536
522/* 537/*