����JFIF���������
__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
/*
* NETLINK Netlink attributes
*
* Copyright (c) 2003-2013 Thomas Graf <tgraf@suug.ch>
*/
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <linux/rtnetlink.h>
#include "nlattr.h"
#include "libbpf_internal.h"
static uint16_t nla_attr_minlen[LIBBPF_NLA_TYPE_MAX+1] = {
[LIBBPF_NLA_U8] = sizeof(uint8_t),
[LIBBPF_NLA_U16] = sizeof(uint16_t),
[LIBBPF_NLA_U32] = sizeof(uint32_t),
[LIBBPF_NLA_U64] = sizeof(uint64_t),
[LIBBPF_NLA_STRING] = 1,
[LIBBPF_NLA_FLAG] = 0,
};
static struct nlattr *nla_next(const struct nlattr *nla, int *remaining)
{
int totlen = NLA_ALIGN(nla->nla_len);
*remaining -= totlen;
return (struct nlattr *)((void *)nla + totlen);
}
static int nla_ok(const struct nlattr *nla, int remaining)
{
return remaining >= (int)sizeof(*nla) &&
nla->nla_len >= sizeof(*nla) &&
nla->nla_len <= remaining;
}
static int nla_type(const struct nlattr *nla)
{
return nla->nla_type & NLA_TYPE_MASK;
}
static int validate_nla(struct nlattr *nla, int maxtype,
struct libbpf_nla_policy *policy)
{
struct libbpf_nla_policy *pt;
unsigned int minlen = 0;
int type = nla_type(nla);
if (type < 0 || type > maxtype)
return 0;
pt = &policy[type];
if (pt->type > LIBBPF_NLA_TYPE_MAX)
return 0;
if (pt->minlen)
minlen = pt->minlen;
else if (pt->type != LIBBPF_NLA_UNSPEC)
minlen = nla_attr_minlen[pt->type];
if (libbpf_nla_len(nla) < minlen)
return -1;
if (pt->maxlen && libbpf_nla_len(nla) > pt->maxlen)
return -1;
if (pt->type == LIBBPF_NLA_STRING) {
char *data = libbpf_nla_data(nla);
if (data[libbpf_nla_len(nla) - 1] != '\0')
return -1;
}
return 0;
}
static inline int nlmsg_len(const struct nlmsghdr *nlh)
{
return nlh->nlmsg_len - NLMSG_HDRLEN;
}
/**
* Create attribute index based on a stream of attributes.
* @arg tb Index array to be filled (maxtype+1 elements).
* @arg maxtype Maximum attribute type expected and accepted.
* @arg head Head of attribute stream.
* @arg len Length of attribute stream.
* @arg policy Attribute validation policy.
*
* Iterates over the stream of attributes and stores a pointer to each
* attribute in the index array using the attribute type as index to
* the array. Attribute with a type greater than the maximum type
* specified will be silently ignored in order to maintain backwards
* compatibility. If \a policy is not NULL, the attribute will be
* validated using the specified policy.
*
* @see nla_validate
* @return 0 on success or a negative error code.
*/
int libbpf_nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head,
int len, struct libbpf_nla_policy *policy)
{
struct nlattr *nla;
int rem, err;
memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
libbpf_nla_for_each_attr(nla, head, len, rem) {
int type = nla_type(nla);
if (type > maxtype)
continue;
if (policy) {
err = validate_nla(nla, maxtype, policy);
if (err < 0)
goto errout;
}
if (tb[type])
pr_warn("Attribute of type %#x found multiple times in message, "
"previous attribute is being ignored.\n", type);
tb[type] = nla;
}
err = 0;
errout:
return err;
}
/**
* Create attribute index based on nested attribute
* @arg tb Index array to be filled (maxtype+1 elements).
* @arg maxtype Maximum attribute type expected and accepted.
* @arg nla Nested Attribute.
* @arg policy Attribute validation policy.
*
* Feeds the stream of attributes nested into the specified attribute
* to libbpf_nla_parse().
*
* @see libbpf_nla_parse
* @return 0 on success or a negative error code.
*/
int libbpf_nla_parse_nested(struct nlattr *tb[], int maxtype,
struct nlattr *nla,
struct libbpf_nla_policy *policy)
{
return libbpf_nla_parse(tb, maxtype, libbpf_nla_data(nla),
libbpf_nla_len(nla), policy);
}
/* dump netlink extended ack error message */
int libbpf_nla_dump_errormsg(struct nlmsghdr *nlh)
{
struct libbpf_nla_policy extack_policy[NLMSGERR_ATTR_MAX + 1] = {
[NLMSGERR_ATTR_MSG] = { .type = LIBBPF_NLA_STRING },
[NLMSGERR_ATTR_OFFS] = { .type = LIBBPF_NLA_U32 },
};
struct nlattr *tb[NLMSGERR_ATTR_MAX + 1], *attr;
struct nlmsgerr *err;
char *errmsg = NULL;
int hlen, alen;
/* no TLVs, nothing to do here */
if (!(nlh->nlmsg_flags & NLM_F_ACK_TLVS))
return 0;
err = (struct nlmsgerr *)NLMSG_DATA(nlh);
hlen = sizeof(*err);
/* if NLM_F_CAPPED is set then the inner err msg was capped */
if (!(nlh->nlmsg_flags & NLM_F_CAPPED))
hlen += nlmsg_len(&err->msg);
attr = (struct nlattr *) ((void *) err + hlen);
alen = (void *)nlh + nlh->nlmsg_len - (void *)attr;
if (libbpf_nla_parse(tb, NLMSGERR_ATTR_MAX, attr, alen,
extack_policy) != 0) {
pr_warn("Failed to parse extended error attributes\n");
return 0;
}
if (tb[NLMSGERR_ATTR_MSG])
errmsg = (char *) libbpf_nla_data(tb[NLMSGERR_ATTR_MSG]);
pr_warn("Kernel error message: %s\n", errmsg);
return 0;
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Build | File | 263 B | 0644 |
|
| Makefile | File | 10.9 KB | 0644 |
|
| bpf.c | File | 36.63 KB | 0644 |
|
| bpf.h | File | 24.87 KB | 0644 |
|
| bpf_core_read.h | File | 21.89 KB | 0644 |
|
| bpf_endian.h | File | 3.66 KB | 0644 |
|
| bpf_gen_internal.h | File | 2.17 KB | 0644 |
|
| bpf_helpers.h | File | 15.51 KB | 0644 |
|
| bpf_prog_linfo.c | File | 6.14 KB | 0644 |
|
| bpf_tracing.h | File | 32.87 KB | 0644 |
|
| btf.c | File | 142.89 KB | 0644 |
|
| btf.h | File | 19.99 KB | 0644 |
|
| btf_dump.c | File | 69.04 KB | 0644 |
|
| btf_iter.c | File | 4.05 KB | 0644 |
|
| btf_relocate.c | File | 14.32 KB | 0644 |
|
| elf.c | File | 13.48 KB | 0644 |
|
| features.c | File | 17.16 KB | 0644 |
|
| gen_loader.c | File | 37.52 KB | 0644 |
|
| hashmap.c | File | 4.92 KB | 0644 |
|
| hashmap.h | File | 6.74 KB | 0644 |
|
| libbpf.c | File | 375.66 KB | 0644 |
|
| libbpf.h | File | 73.26 KB | 0644 |
|
| libbpf.map | File | 8.86 KB | 0644 |
|
| libbpf.pc.template | File | 252 B | 0644 |
|
| libbpf_common.h | File | 3.36 KB | 0644 |
|
| libbpf_errno.c | File | 2.25 KB | 0644 |
|
| libbpf_internal.h | File | 19.59 KB | 0644 |
|
| libbpf_legacy.h | File | 5.07 KB | 0644 |
|
| libbpf_probes.c | File | 11.87 KB | 0644 |
|
| libbpf_version.h | File | 242 B | 0644 |
|
| linker.c | File | 76.81 KB | 0644 |
|
| netlink.c | File | 21.65 KB | 0644 |
|
| nlattr.c | File | 4.9 KB | 0644 |
|
| nlattr.h | File | 4.23 KB | 0644 |
|
| relo_core.c | File | 50.5 KB | 0644 |
|
| relo_core.h | File | 3.26 KB | 0644 |
|
| ringbuf.c | File | 15.86 KB | 0644 |
|
| skel_internal.h | File | 8.89 KB | 0644 |
|
| str_error.c | File | 1020 B | 0644 |
|
| str_error.h | File | 235 B | 0644 |
|
| strset.c | File | 4.28 KB | 0644 |
|
| strset.h | File | 586 B | 0644 |
|
| usdt.bpf.h | File | 8.31 KB | 0644 |
|
| usdt.c | File | 51.09 KB | 0644 |
|
| zip.c | File | 8.29 KB | 0644 |
|
| zip.h | File | 1.24 KB | 0644 |
|