mirror of
https://github.com/netdata/libbpf.git
synced 2026-03-26 03:09:07 +08:00
Compare commits
14 Commits
v0.6.0
...
v0.6.1_net
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cea98d241 | ||
|
|
e61e089911 | ||
|
|
93e89b3474 | ||
|
|
b9d46530c3 | ||
|
|
86175df408 | ||
|
|
720324afab | ||
|
|
aea40f7179 | ||
|
|
54a7bc87d5 | ||
|
|
9979463ccf | ||
|
|
b91ca01922 | ||
|
|
8ded7c6db0 | ||
|
|
7df4ea0f0d | ||
|
|
02333ba360 | ||
|
|
6921017d25 |
93
src/libbpf.c
93
src/libbpf.c
@@ -812,6 +812,93 @@ bpf_object__add_programs(struct bpf_object *obj, Elf_Data *sec_data,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __u32 choose_specific_version0(int fd, __u32 current)
|
||||||
|
{
|
||||||
|
char ver[256];
|
||||||
|
__u32 v_major, v_minor, v_patch;
|
||||||
|
ssize_t len = read(fd, ver, sizeof(ver));
|
||||||
|
if (len < 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ver[len] = '\0';
|
||||||
|
|
||||||
|
char *first = strchr(ver, ' ');
|
||||||
|
if (!first) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
first++;
|
||||||
|
char *version = strchr(first, ' ');
|
||||||
|
if (!version) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
version++;
|
||||||
|
if (sscanf(version, "%u.%u.%u", &v_major, &v_minor, &v_patch) != 3)
|
||||||
|
return current;
|
||||||
|
|
||||||
|
return KERNEL_VERSION(v_major, v_minor, v_patch);
|
||||||
|
}
|
||||||
|
|
||||||
|
static __u32 choose_kernel_version(__u32 current)
|
||||||
|
{
|
||||||
|
FILE *fp_d = fopen("/etc/debian_version","r");
|
||||||
|
int fp_u = open("/proc/version_signature", O_RDONLY);
|
||||||
|
FILE *fp_rh = fopen("/etc/redhat-release","r");
|
||||||
|
char tmp[32];
|
||||||
|
int de = 0;
|
||||||
|
__u32 ret;
|
||||||
|
|
||||||
|
if (!fp_d && !fp_rh && fp_u == -1)
|
||||||
|
return current;
|
||||||
|
|
||||||
|
struct utsname u;
|
||||||
|
uname(&u);
|
||||||
|
|
||||||
|
if (fp_d) {
|
||||||
|
fclose(fp_d);
|
||||||
|
de = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fp_rh) {
|
||||||
|
fclose(fp_rh);
|
||||||
|
de = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( fp_u > 0 ) {
|
||||||
|
ret = choose_specific_version0(fp_u, current);
|
||||||
|
close(fp_u);
|
||||||
|
return (!ret)?current:ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
__u32 v_kernel,v_major, v_minor, v_patch;
|
||||||
|
__u32 r_kernel,r_major, r_minor, r_patch;
|
||||||
|
|
||||||
|
if (sscanf(u.release, "%u.%u.%u-%u", &v_kernel, &v_major, &v_minor, &v_patch) != 4)
|
||||||
|
return current;
|
||||||
|
|
||||||
|
int length = snprintf(tmp, 31, "%u.%u", v_kernel, v_major);
|
||||||
|
tmp[length] = '\0';
|
||||||
|
|
||||||
|
char *parse = strstr(u.version, tmp);
|
||||||
|
if (!parse) {
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *space = strchr(parse, ' ');
|
||||||
|
if(space) {
|
||||||
|
length = (int)(space - parse);
|
||||||
|
strncpy(tmp, parse, (size_t)length);
|
||||||
|
tmp[length] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sscanf(tmp, "%u.%u.%u-%u", &r_kernel, &r_major, &r_minor, &r_patch) != 4)
|
||||||
|
return current;
|
||||||
|
|
||||||
|
ret = (de)?KERNEL_VERSION(r_kernel, r_major, r_minor):KERNEL_VERSION(r_kernel, r_major, r_minor) + r_patch;
|
||||||
|
return (ret > current)?ret:current;
|
||||||
|
}
|
||||||
|
|
||||||
static __u32 get_kernel_version(void)
|
static __u32 get_kernel_version(void)
|
||||||
{
|
{
|
||||||
__u32 major, minor, patch;
|
__u32 major, minor, patch;
|
||||||
@@ -820,7 +907,11 @@ static __u32 get_kernel_version(void)
|
|||||||
uname(&info);
|
uname(&info);
|
||||||
if (sscanf(info.release, "%u.%u.%u", &major, &minor, &patch) != 3)
|
if (sscanf(info.release, "%u.%u.%u", &major, &minor, &patch) != 3)
|
||||||
return 0;
|
return 0;
|
||||||
return KERNEL_VERSION(major, minor, patch);
|
|
||||||
|
if (major < 5)
|
||||||
|
return choose_kernel_version(KERNEL_VERSION(major, minor, patch));
|
||||||
|
else
|
||||||
|
return KERNEL_VERSION(major, minor, patch);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct btf_member *
|
static const struct btf_member *
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ $ sudo systemctl restart actions-runner-libbpf
|
|||||||
The `actions-runner-libbpf` service stores various temporary data, such as
|
The `actions-runner-libbpf` service stores various temporary data, such as
|
||||||
runner registration information, work directories and logs, in the
|
runner registration information, work directories and logs, in the
|
||||||
`actions-runner-libbpf` volume. In order to remove it and start from scratch,
|
`actions-runner-libbpf` volume. In order to remove it and start from scratch,
|
||||||
e.g. when switching the runner to a different repository, use the following
|
e.g. when upgrading the runner or switching it to a different repository, use
|
||||||
commands:
|
the following commands:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ sudo systemctl stop actions-runner-libbpf
|
$ sudo systemctl stop actions-runner-libbpf
|
||||||
|
|||||||
@@ -33,13 +33,14 @@ RUN ln -fs /etc/resolv.conf /usr/x86_64-linux-gnu/etc/
|
|||||||
ENV QEMU_LD_PREFIX=/usr/x86_64-linux-gnu
|
ENV QEMU_LD_PREFIX=/usr/x86_64-linux-gnu
|
||||||
|
|
||||||
# amd64 Github Actions Runner.
|
# amd64 Github Actions Runner.
|
||||||
|
ARG version=2.285.0
|
||||||
RUN useradd -m actions-runner
|
RUN useradd -m actions-runner
|
||||||
RUN echo "actions-runner ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
|
RUN echo "actions-runner ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
|
||||||
RUN echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >>/etc/sudoers
|
RUN echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >>/etc/sudoers
|
||||||
USER actions-runner
|
USER actions-runner
|
||||||
ENV USER=actions-runner
|
ENV USER=actions-runner
|
||||||
WORKDIR /home/actions-runner
|
WORKDIR /home/actions-runner
|
||||||
RUN curl -L https://github.com/actions/runner/releases/download/v2.283.2/actions-runner-linux-x64-2.283.2.tar.gz | tar -xz
|
RUN curl -L https://github.com/actions/runner/releases/download/v${version}/actions-runner-linux-x64-${version}.tar.gz | tar -xz
|
||||||
VOLUME /home/actions-runner
|
VOLUME /home/actions-runner
|
||||||
|
|
||||||
# Scripts.
|
# Scripts.
|
||||||
|
|||||||
Reference in New Issue
Block a user