Commit cd1dc96a authored by jianqiang Li's avatar jianqiang Li Committed by mufengyan
Browse files

UNIC: The ublhdr structure and UBL_HLEN macro are modified

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IATZWZ


CVE: NA

-----------------------------------------------------------

When the raw socket is sent, the actual offset between the
network header and skb->data in the packet is 7 bytes. (1
byte of sw_ctype and 6 bytes of UBL_HLEN) In the kernel,
skb->network_header is offset by dev->hard_header_len bytes
(UBL_HLEN = 6). As a result, the value of dscp cannot be
obtained correctly in the .ndo_select_queue function.
Therefore, multiple tc cannot be specified by specifying tos
when sending the raw socket. To solve this problem, the cfg
field is added to struct ublhdr and the value of UBL_HLEN is
changed from 6 to 7.

Fixes: eb44201e ("ubl: add CONFIG_UBL definition and UBL interface")
Signed-off-by: default avatarchuan Wu <wuchuan4@huawei.com>
Signed-off-by: default avatarjianqiang Li <lijianqiang16@huawei.com>
parent 2948184a
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -84,25 +84,19 @@ static int ubl_create_header(struct sk_buff *skb, struct net_device *dev,
			     unsigned short type, const void *daddr,
			     const void *saddr, unsigned int len)
{
	u8 ctype = UB_NOIP_CFG_TYPE;
	int ret = -UBL_HLEN;
	struct ublhdr *ubl;

	if (type == ETH_P_IP || type == ETH_P_IPV6) {
		ubl = (struct ublhdr *)skb_push(skb, UBL_HLEN);
		memset(ubl, 0, sizeof(struct ublhdr));
		ubl->h_npi = htonl(UB_DEFAULT_NPI);
		ctype = (type == ETH_P_IP) ? UB_IPV4_CFG_TYPE : UB_IPV6_CFG_TYPE;
		ret = UBL_HLEN;
		ubl->cfg = (type == ETH_P_IP) ? UB_IPV4_CFG_TYPE : UB_IPV6_CFG_TYPE;
		return UBL_HLEN;
	} else if (type == ETH_P_UB) {
		/* if type is ETH_P_UB, then do nothing. */
		ret = 0;
		return 0;
	}

	if (ubl_add_sw_ctype(skb, ctype))
		ret = -ENOMEM;

	return ret;
	return -UBL_HLEN;
}

/**
@@ -184,7 +178,7 @@ __be16 ubl_type_trans(struct sk_buff *skb, struct net_device *dev, u8 type)

	skb_reset_mac_header(skb);
	if (type == UB_IPV4_CFG_TYPE || type == UB_IPV6_CFG_TYPE)
		skb_pull_inline(skb, UBL_HLEN + 1);
		skb_pull_inline(skb, UBL_HLEN);
	else if (type != UB_NOIP_CFG_TYPE)
		net_warn_ratelimited("An unknown packet is received by %s, type is %u\n",
				     dev->name, type);
+8 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@
#define UBL_MOD_VERSION "1.0.0"

#define UBL_HARD_HLEN		4
#define UBL_HLEN		6
#define UBL_HLEN		7
#define UBL_ALEN		16

#define UBL_LCRC_LEN		2
@@ -55,6 +55,13 @@
 *	@h_npi: network partition identifier
 */
struct ublhdr {
#if defined(__LITTLE_ENDIAN_BITFIELD)
	u8     cfg : 4;
	u8     resv : 4;
#else
	u8     resv : 4;
	u8     cfg : 4;
#endif
	__be16 h_cc;
	__be32 h_npi;
} __packed;