Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Verlässliche Systemsoftware
projects
osv
Commits
e73703e5
Commit
e73703e5
authored
12 years ago
by
Guy Zana
Browse files
Options
Downloads
Patches
Plain Diff
Ported ip_icmp
parent
32a98488
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bsd/porting/netport.c
+22
-0
22 additions, 0 deletions
bsd/porting/netport.c
bsd/porting/netport.h
+19
-0
19 additions, 0 deletions
bsd/porting/netport.h
bsd/sys/netinet/ip_icmp.c
+38
-28
38 additions, 28 deletions
bsd/sys/netinet/ip_icmp.c
with
79 additions
and
28 deletions
bsd/porting/netport.c
+
22
−
0
View file @
e73703e5
#include
<errno.h>
#include
<memory.h>
#include
<time.h>
#include
<bsd/porting/netport.h>
#include
<bsd/sys/sys/socket.h>
...
...
@@ -176,3 +177,24 @@ pru_sopoll_notsupp(struct socket *so, int events, struct ucred *cred,
return
EOPNOTSUPP
;
}
int
ppsratecheck
(
struct
timeval
*
lasttime
,
int
*
curpps
,
int
maxpps
)
{
struct
timeval
now
;
getmicrotime
(
&
now
);
uint64_t
now2
=
now
.
tv_sec
*
hz
+
now
.
tv_usec
;
/*
* Reset the last time and counter if this is the first call
* or more than a second has passed since the last update of
* lasttime.
*/
if
(
lasttime
->
tv_sec
==
0
||
(
u_int
)(
now2
-
lasttime
->
tv_sec
)
>=
hz
)
{
lasttime
->
tv_sec
=
now2
;
*
curpps
=
1
;
return
(
maxpps
!=
0
);
}
else
{
(
*
curpps
)
++
;
/* NB: ignore potential overflow */
return
(
maxpps
<
0
||
*
curpps
<
maxpps
);
}
}
This diff is collapsed.
Click to expand it.
bsd/porting/netport.h
+
19
−
0
View file @
e73703e5
...
...
@@ -291,4 +291,23 @@ static __inline intrmask_t spltty(void) { return 0; }
static
__inline
intrmask_t
splvm
(
void
)
{
return
0
;
}
static
__inline
void
splx
(
intrmask_t
ipl
)
{
return
;
}
/*
* OSv: Copied from kern_time.c
*
* ppsratecheck(): packets (or events) per second limitation.
*
* Return 0 if the limit is to be enforced (e.g. the caller
* should drop a packet because of the rate limitation).
*
* maxpps of 0 always causes zero to be returned. maxpps of -1
* always causes 1 to be returned; this effectively defeats rate
* limiting.
*
* Note that we maintain the struct timeval for compatibility
* with other bsd systems. We reuse the storage and just monitor
* clock ticks for minimal overhead.
*/
int
ppsratecheck
(
struct
timeval
*
lasttime
,
int
*
curpps
,
int
maxpps
);
#endif
This diff is collapsed.
Click to expand it.
bsd/sys/netinet/ip_icmp.c
+
38
−
28
View file @
e73703e5
...
...
@@ -30,38 +30,35 @@
*/
#include
<sys/cdefs.h>
__FBSDID
(
"$FreeBSD$"
);
#include
"opt_inet.h"
#include
"opt_ipsec.h"
#include
<bsd/porting/netport.h>
#include
<sys/param.h>
#include
<sys/sys
t
m.h>
#include
<sys/mbuf.h>
#include
<sys/protosw.h>
#include
<sys/socket.h>
#include
<
bsd/
sys/sys
/para
m.h>
#include
<
bsd/sys/
sys/mbuf.h>
#include
<
bsd/sys/
sys/protosw.h>
#include
<
bsd/sys/
sys/socket.h>
#include
<sys/time.h>
#include
<sys/kernel.h>
#include
<sys/sysctl.h>
#include
<sys/syslog.h>
#include
<net/if.h>
#include
<net/if_types.h>
#include
<net/route.h>
#include
<net/vnet.h>
#include
<netinet/in.h>
#include
<netinet/in_pcb.h>
#include
<netinet/in_systm.h>
#include
<netinet/in_var.h>
#include
<netinet/ip.h>
#include
<netinet/ip_icmp.h>
#include
<netinet/ip_var.h>
#include
<bsd/sys/net/if.h>
#include
<bsd/sys/net/if_types.h>
#include
<bsd/sys/net/route.h>
#include
<bsd/sys/net/vnet.h>
#include
<bsd/sys/netinet/in.h>
#include
<bsd/sys/netinet/in_pcb.h>
#include
<bsd/sys/netinet/in_systm.h>
#include
<bsd/sys/netinet/in_var.h>
#include
<bsd/sys/netinet/ip.h>
#include
<bsd/sys/netinet/ip_icmp.h>
#include
<bsd/sys/netinet/ip_var.h>
#if 0
#include <netinet/ip_options.h>
#include
<netinet/tcp.h>
#include <
bsd/sys/
netinet/tcp.h>
#include <netinet/tcp_var.h>
#include <netinet/tcpip.h>
#include
<netinet/icmp_var.h>
#endif
#include
<bsd/sys/netinet/icmp_var.h>
#ifdef INET
#ifdef IPSEC
...
...
@@ -69,9 +66,8 @@ __FBSDID("$FreeBSD$");
#include
<netipsec/key.h>
#endif
#include
<machine/in_cksum.h>
#include
<
bsd/
machine/in_cksum.h>
#include
<security/mac/mac_framework.h>
#endif
/* INET */
/*
...
...
@@ -128,11 +124,13 @@ SYSCTL_VNET_INT(_net_inet_icmp, OID_AUTO, reply_from_interface, CTLFLAG_RW,
&
VNET_NAME
(
icmp_rfi
),
0
,
"ICMP reply from incoming interface for non-local packets"
);
#if 0
static VNET_DEFINE(int, icmp_quotelen) = 8;
#define V_icmp_quotelen VNET(icmp_quotelen)
SYSCTL_VNET_INT(_net_inet_icmp, OID_AUTO, quotelen, CTLFLAG_RW,
&VNET_NAME(icmp_quotelen), 0,
"Number of bytes from original packet to quote in ICMP reply");
#endif
/*
* ICMP broadcast echo sysctl
...
...
@@ -153,6 +151,8 @@ static void icmp_send(struct mbuf *, struct mbuf *);
extern
struct
protosw
inetsw
[];
/* FIXME: OSV: sysctl_net_icmp_drop_redir() ignore redirects */
#if 0
static int
sysctl_net_icmp_drop_redir(SYSCTL_HANDLER_ARGS)
{
...
...
@@ -185,6 +185,7 @@ sysctl_net_icmp_drop_redir(SYSCTL_HANDLER_ARGS)
SYSCTL_VNET_PROC(_net_inet_icmp, OID_AUTO, drop_redirect,
CTLTYPE_INT|CTLFLAG_RW, 0, 0,
sysctl_net_icmp_drop_redir, "I", "Ignore ICMP redirects");
#endif
/*
* Kernel module interface for updating icmpstat. The argument is an index
...
...
@@ -200,6 +201,8 @@ kmod_icmpstat_inc(int statnum)
(
*
((
u_long
*
)
&
V_icmpstat
+
statnum
))
++
;
}
/* FIXME: OSv - this is still unsupported */
#if 0
/*
* Generate an error packet of type error
* in response to bad packet ip.
...
...
@@ -348,6 +351,7 @@ stdreply: icmpelen = max(8, min(V_icmp_quotelen, oip->ip_len - oiphlen));
freeit:
m_freem(n);
}
#endif
/*
* Process a received ICMP message.
...
...
@@ -813,7 +817,13 @@ match:
* add on any record-route or timestamp options.
*/
cp
=
(
u_char
*
)
(
ip
+
1
);
/* FIXME: OSv - enable when we have ip options */
#if 0
if ((opts = ip_srcroute(m)) == 0 &&
#else
opts
=
0
;
if
(
opts
&&
#endif
(
opts
=
m_gethdr
(
M_DONTWAIT
,
MT_DATA
)))
{
opts
->
m_len
=
sizeof
(
struct
in_addr
);
mtod
(
opts
,
struct
in_addr
*
)
->
s_addr
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment