Unverified Commit 50b22902 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!2890 net: ipv6: addrconf: Add the IPv6 link local address of the UB port.

Merge Pull Request from: @li-jiewei999 
 

drivers inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8H6KX


CVE: NA

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

1、In the kernel, use the high 24 bits (OUT) and low 40 bits (serial number) of 
the GUID to generate the IPv6 link local address of the UB port.

Signed-off-by: default avatarGe Hu <huge4@huawei.com>
Signed-off-by: default avatarZhongyuan Zhou <zhouzhongyuan1@huawei.com>
Signed-off-by: default avatarYutian Jiang <jiangyutian1@huawei.com>
Signed-off-by: default avatarJeiwei Li <lijiewei5@huawei.com>
 
Link:https://gitee.com/openeuler/kernel/pulls/2890

 

Reviewed-by: default avatarYue Haibing <yuehaibing@huawei.com>
Reviewed-by: default avatarLin Yunsheng <linyunsheng@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents f800f22b a33d1b2d
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -2268,6 +2268,21 @@ static int addrconf_ifid_infiniband(u8 *eui, struct net_device *dev)
	return 0;
}

static int addrconf_ifid_ub(u8 *eui, struct net_device *dev)
{
#define GUID_LEN 16
#define OUI_LEN 3
#define SEQ_NUM_OFFSET 11
#define SEQ_NUM_LEN 5

	if (dev->addr_len != GUID_LEN)
		return -1;
	memcpy(eui, dev->dev_addr, OUI_LEN);
	memcpy(eui + OUI_LEN, dev->dev_addr + SEQ_NUM_OFFSET, SEQ_NUM_LEN);
	eui[0] |= 2;
	return 0;
}

static int __ipv6_isatap_ifid(u8 *eui, __be32 addr)
{
	if (addr == 0)
@@ -2330,6 +2345,8 @@ static int ipv6_generate_eui64(u8 *eui, struct net_device *dev)
	case ARPHRD_IP6GRE:
	case ARPHRD_RAWIP:
		return addrconf_ifid_ip6tnl(eui, dev);
	case ARPHRD_UB:
		return addrconf_ifid_ub(eui, dev);
	}
	return -1;
}
@@ -3362,7 +3379,8 @@ static void addrconf_dev_config(struct net_device *dev)
	    (dev->type != ARPHRD_IPGRE) &&
	    (dev->type != ARPHRD_TUNNEL) &&
	    (dev->type != ARPHRD_NONE) &&
	    (dev->type != ARPHRD_RAWIP)) {
	    (dev->type != ARPHRD_RAWIP) &&
	    (dev->type != ARPHRD_UB)) {
		/* Alas, we support only Ethernet autoconfiguration. */
		idev = __in6_dev_get(dev);
		if (!IS_ERR_OR_NULL(idev) && dev->flags & IFF_UP &&