Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bpf: Remove attach_type in sockmap_link

Use attach_type in bpf_link, and remove it in sockmap_link.

Signed-off-by: Tao Chen <chen.dylane@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20250710032038.888700-4-chen.dylane@linux.dev

authored by

Tao Chen and committed by
Andrii Nakryiko
33f69f73 9b8d543d

+4 -6
+4 -6
net/core/sock_map.c
··· 1709 1709 struct sockmap_link { 1710 1710 struct bpf_link link; 1711 1711 struct bpf_map *map; 1712 - enum bpf_attach_type attach_type; 1713 1712 }; 1714 1713 1715 1714 static void sock_map_link_release(struct bpf_link *link) ··· 1720 1721 goto out; 1721 1722 1722 1723 WARN_ON_ONCE(sock_map_prog_update(sockmap_link->map, NULL, link->prog, link, 1723 - sockmap_link->attach_type)); 1724 + link->attach_type)); 1724 1725 1725 1726 bpf_map_put_with_uref(sockmap_link->map); 1726 1727 sockmap_link->map = NULL; ··· 1771 1772 } 1772 1773 1773 1774 ret = sock_map_prog_link_lookup(sockmap_link->map, &pprog, &plink, 1774 - sockmap_link->attach_type); 1775 + link->attach_type); 1775 1776 if (ret) 1776 1777 goto out; 1777 1778 ··· 1816 1817 u32 map_id = sock_map_link_get_map_id(sockmap_link); 1817 1818 1818 1819 info->sockmap.map_id = map_id; 1819 - info->sockmap.attach_type = sockmap_link->attach_type; 1820 + info->sockmap.attach_type = link->attach_type; 1820 1821 return 0; 1821 1822 } 1822 1823 ··· 1827 1828 u32 map_id = sock_map_link_get_map_id(sockmap_link); 1828 1829 1829 1830 seq_printf(seq, "map_id:\t%u\n", map_id); 1830 - seq_printf(seq, "attach_type:\t%u\n", sockmap_link->attach_type); 1831 + seq_printf(seq, "attach_type:\t%u\n", link->attach_type); 1831 1832 } 1832 1833 1833 1834 static const struct bpf_link_ops sock_map_link_ops = { ··· 1868 1869 bpf_link_init(&sockmap_link->link, BPF_LINK_TYPE_SOCKMAP, &sock_map_link_ops, prog, 1869 1870 attach_type); 1870 1871 sockmap_link->map = map; 1871 - sockmap_link->attach_type = attach_type; 1872 1872 1873 1873 ret = bpf_link_prime(&sockmap_link->link, &link_primer); 1874 1874 if (ret) {