From: Patrick McHardy <kaber@trash.net>
To: lartc@vger.kernel.org
Subject: [LARTC] set skb->priority with ping
Date: Thu, 18 Apr 2002 15:25:16 +0000 [thread overview]
Message-ID: <marc-lartc-101914368423554@msgid-missing> (raw)
[-- Attachment #1: Type: text/plain, Size: 344 bytes --]
Hi !
While playing around with skb->priority i made a new option -P for ping
to direct icmp echo packets to a particular class. It's not very useful
because it only has any effect if no filter are attached to the parent
(at least i think so), but maybe someone else finds it useful.
The patch applies against iputils-ss020124.
Bye,
Patrick
[-- Attachment #2: ping.diff --]
[-- Type: text/plain, Size: 2076 bytes --]
--- iputils/ping.c Sun Dec 2 19:28:32 2001
+++ iputils-prio/ping.c Thu Apr 18 17:06:54 2002
@@ -79,6 +79,7 @@
struct sockaddr_in whereto; /* who to ping */
int optlen = 0;
int settos = 0; /* Set TOS, Precendence or other QOS options */
+int priority = 0; /* skb->priority */
int icmp_sock; /* socket file descriptor */
u_char outpack[0x10000];
int maxpacket = sizeof(outpack);
@@ -92,6 +93,7 @@
static u_short in_cksum(const u_short *addr, int len, u_short salt);
static void pr_icmph(__u8 type, __u8 code, __u32 info, struct icmphdr *icp);
static int parsetos(char *str);
+static int parsepriority(const char *str);
static struct {
struct cmsghdr cm;
@@ -124,7 +126,7 @@
source.sin_family = AF_INET;
preload = 1;
- while ((ch = getopt(argc, argv, COMMON_OPTSTR "bRT:")) != EOF) {
+ while ((ch = getopt(argc, argv, COMMON_OPTSTR "bRT:P:")) != EOF) {
switch(ch) {
case 'b':
broadcast_pings = 1;
@@ -138,6 +140,15 @@
exit(2);
}
break;
+ case 'P':
+ priority = parsepriority(optarg);
+ if (priority &&
+ (setsockopt(icmp_sock, SOL_SOCKET, SO_PRIORITY,
+ (char *)&priority, sizeof(int)) < 0)) {
+ perror("ping: error setting priority");
+ exit(2);
+ }
+ break;
case 'R':
if (options & F_TIMESTAMP) {
fprintf(stderr, "Only one of -T or -R may be used\n");
@@ -1158,6 +1169,18 @@
return(tos);
}
+#include <linux/pkt_sched.h>
+
+int parsepriority(const char *str)
+{
+ char *sep;
+
+ if ((sep = strstr(str, ":")) == NULL)
+ return atoi(str);
+ *sep = '\0';
+ return TC_H_MAKE(atoi(str) << 16, atoi(sep + 1));
+}
+
#include <linux/filter.h>
void install_filter(void)
@@ -1196,6 +1219,6 @@
"Usage: ping [-LRUbdfnqrvVaA] [-c count] [-i interval] [-w deadline]\n"
" [-p pattern] [-s packetsize] [-t ttl] [-I interface or address]\n"
" [-M mtu discovery hint] [-S sndbuf]\n"
-" [ -T timestamp option ] [ -Q tos ] [hop1 ...] destination\n");
+" [ -T timestamp option ] [ -Q tos ] [ -P classid ] [hop1 ...] destination\n");
exit(2);
}
reply other threads:[~2002-04-18 15:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-lartc-101914368423554@msgid-missing \
--to=kaber@trash.net \
--cc=lartc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox