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

Commit 6556c385 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'dropcount'



Eyal Birger says:

====================
net: move skb->dropcount to skb->cb[]

Commit 97775007 ("af_packet: add interframe drop cmsg (v6)")
unionized skb->mark and skb->dropcount in order to allow recording
of the socket drop count while maintaining struct sk_buff size.

skb->dropcount was introduced since there was no available room
in skb->cb[] in packet sockets. However, its introduction led to
the inability to export skb->mark to userspace.

It was considered to alias skb->priority instead of skb->mark.
However, that would lead to the inabilty to export skb->priority
to userspace if desired. Such change may also lead to hard-to-find
issues as skb->priority is assumed to be alias free, and, as noted
by Shmulik Ladkani, is not 'naturally orthogonal' with other skb
fields.

This patch series follows the suggestions made by Eric Dumazet moving
the dropcount metric to skb->cb[], eliminating this problem
at the expense of 4 bytes less in skb->cb[] for protocol families
using it.

The patch series include compactization of bluetooth and packet
use of skb->cb[] as well as the infrastructure for placing dropcount
in skb->cb[].
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 287f3a94 744d5a3e
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -492,7 +492,6 @@ static inline u32 skb_mstamp_us_delta(const struct skb_mstamp *t1,
  *	@napi_id: id of the NAPI struct this skb came from
 *	@secmark: security marking
 *	@mark: Generic packet mark
 *	@dropcount: total number of sk_receive_queue overflows
 *	@vlan_proto: vlan encapsulation protocol
 *	@vlan_tci: vlan tag control information
 *	@inner_protocol: Protocol (encapsulation)
@@ -641,7 +640,6 @@ struct sk_buff {
#endif
	union {
		__u32		mark;
		__u32		dropcount;
		__u32		reserved_tailroom;
	};

+5 −9
Original line number Diff line number Diff line
@@ -275,21 +275,17 @@ struct hci_dev;

typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode);

struct hci_req_ctrl {
	bool			start;
	u8			event;
	hci_req_complete_t	complete;
};

struct bt_skb_cb {
	__u8 pkt_type;
	__u8 incoming;
	__u8 force_active;
	__u16 opcode;
	__u16 expect;
	__u8 force_active;
	__u8 incoming:1;
	__u8 req_start:1;
	u8 req_event;
	hci_req_complete_t req_complete;
	struct l2cap_chan *chan;
	struct l2cap_ctrl control;
	struct hci_req_ctrl req;
	bdaddr_t bdaddr;
	__le16 psm;
};
+23 −0
Original line number Diff line number Diff line
@@ -2078,6 +2078,29 @@ static inline int sock_intr_errno(long timeo)
	return timeo == MAX_SCHEDULE_TIMEOUT ? -ERESTARTSYS : -EINTR;
}

struct sock_skb_cb {
	u32 dropcount;
};

/* Store sock_skb_cb at the end of skb->cb[] so protocol families
 * using skb->cb[] would keep using it directly and utilize its
 * alignement guarantee.
 */
#define SOCK_SKB_CB_OFFSET ((FIELD_SIZEOF(struct sk_buff, cb) - \
			    sizeof(struct sock_skb_cb)))

#define SOCK_SKB_CB(__skb) ((struct sock_skb_cb *)((__skb)->cb + \
			    SOCK_SKB_CB_OFFSET))

#define sock_skb_cb_check_size(size) \
	BUILD_BUG_ON((size) > SOCK_SKB_CB_OFFSET)

static inline void
sock_skb_set_dropcount(const struct sock *sk, struct sk_buff *skb)
{
	SOCK_SKB_CB(skb)->dropcount = atomic_read(&sk->sk_drops);
}

void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
			   struct sk_buff *skb);
void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk,
+1 −2
Original line number Diff line number Diff line
@@ -711,10 +711,9 @@ EXPORT_SYMBOL_GPL(bt_debugfs);

static int __init bt_init(void)
{
	struct sk_buff *skb;
	int err;

	BUILD_BUG_ON(sizeof(struct bt_skb_cb) > sizeof(skb->cb));
	sock_skb_cb_check_size(sizeof(struct bt_skb_cb));

	BT_INFO("Core ver %s", VERSION);

+6 −6
Original line number Diff line number Diff line
@@ -3517,7 +3517,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen,
	/* Stand-alone HCI commands must be flagged as
	 * single-command requests.
	 */
	bt_cb(skb)->req.start = true;
	bt_cb(skb)->req_start = 1;

	skb_queue_tail(&hdev->cmd_q, skb);
	queue_work(hdev->workqueue, &hdev->cmd_work);
@@ -4195,7 +4195,7 @@ static bool hci_req_is_complete(struct hci_dev *hdev)
	if (!skb)
		return true;

	return bt_cb(skb)->req.start;
	return bt_cb(skb)->req_start;
}

static void hci_resend_last(struct hci_dev *hdev)
@@ -4255,14 +4255,14 @@ void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status)
	 * command queue (hdev->cmd_q).
	 */
	if (hdev->sent_cmd) {
		req_complete = bt_cb(hdev->sent_cmd)->req.complete;
		req_complete = bt_cb(hdev->sent_cmd)->req_complete;

		if (req_complete) {
			/* We must set the complete callback to NULL to
			 * avoid calling the callback more than once if
			 * this function gets called again.
			 */
			bt_cb(hdev->sent_cmd)->req.complete = NULL;
			bt_cb(hdev->sent_cmd)->req_complete = NULL;

			goto call_complete;
		}
@@ -4271,12 +4271,12 @@ void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status)
	/* Remove all pending commands belonging to this request */
	spin_lock_irqsave(&hdev->cmd_q.lock, flags);
	while ((skb = __skb_dequeue(&hdev->cmd_q))) {
		if (bt_cb(skb)->req.start) {
		if (bt_cb(skb)->req_start) {
			__skb_queue_head(&hdev->cmd_q, skb);
			break;
		}

		req_complete = bt_cb(skb)->req.complete;
		req_complete = bt_cb(skb)->req_complete;
		kfree_skb(skb);
	}
	spin_unlock_irqrestore(&hdev->cmd_q.lock, flags);
Loading