Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  sockopt_multi.c   Sprache: C

 
// SPDX-License-Identifier: GPL-2.0
#include <netinet/in.h>
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>

char _license[] SEC("license") = "GPL";

__s32 page_size = 0;

SEC("cgroup/getsockopt")
int _getsockopt_child(struct bpf_sockopt *ctx)
{
 __u8 *optval_end = ctx->optval_end;
 __u8 *optval = ctx->optval;

 if (ctx->level != SOL_IP || ctx->optname != IP_TOS)
  goto out;

 if (optval + 1 > optval_end)
  return 0; /* EPERM, bounds check */

 if (optval[0] != 0x80)
  return 0; /* EPERM, unexpected optval from the kernel */

 ctx->retval = 0; /* Reset system call return value to zero */

 optval[0] = 0x90;
 ctx->optlen = 1;

 return 1;

out:
 /* optval larger than PAGE_SIZE use kernel's buffer. */
 if (ctx->optlen > page_size)
  ctx->optlen = 0;
 return 1;
}

SEC("cgroup/getsockopt")
int _getsockopt_parent(struct bpf_sockopt *ctx)
{
 __u8 *optval_end = ctx->optval_end;
 __u8 *optval = ctx->optval;

 if (ctx->level != SOL_IP || ctx->optname != IP_TOS)
  goto out;

 if (optval + 1 > optval_end)
  return 0; /* EPERM, bounds check */

 if (optval[0] != 0x90)
  return 0; /* EPERM, unexpected optval from the kernel */

 ctx->retval = 0; /* Reset system call return value to zero */

 optval[0] = 0xA0;
 ctx->optlen = 1;

 return 1;

out:
 /* optval larger than PAGE_SIZE use kernel's buffer. */
 if (ctx->optlen > page_size)
  ctx->optlen = 0;
 return 1;
}

SEC("cgroup/setsockopt")
int _setsockopt(struct bpf_sockopt *ctx)
{
 __u8 *optval_end = ctx->optval_end;
 __u8 *optval = ctx->optval;

 if (ctx->level != SOL_IP || ctx->optname != IP_TOS)
  goto out;

 if (optval + 1 > optval_end)
  return 0; /* EPERM, bounds check */

 optval[0] += 0x10;
 ctx->optlen = 1;

 return 1;

out:
 /* optval larger than PAGE_SIZE use kernel's buffer. */
 if (ctx->optlen > page_size)
  ctx->optlen = 0;
 return 1;
}

Messung V0.5
C=88 H=82 G=84

¤ Dauer der Verarbeitung: 0.22 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge