Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
0ccba642
Commit
0ccba642
authored
Aug 24, 2021
by
Jialin Li
Browse files
tofino: fix arp request bug
parent
edb4215d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
sims/tofino/tofino.cc
sims/tofino/tofino.cc
+3
-3
No files found.
sims/tofino/tofino.cc
View file @
0ccba642
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <net/if.h>
#include <net/ethernet.h>
#include <linux/if_packet.h>
#include <linux/if_packet.h>
#include <vector>
#include <vector>
...
@@ -44,7 +45,6 @@ extern "C" {
...
@@ -44,7 +45,6 @@ extern "C" {
static
uint64_t
sync_period
=
(
500
*
1000ULL
);
static
uint64_t
sync_period
=
(
500
*
1000ULL
);
static
uint64_t
eth_latency
=
(
500
*
1000ULL
);
// 500ns
static
uint64_t
eth_latency
=
(
500
*
1000ULL
);
// 500ns
static
const
int
ETHER_TYPE
=
0x0800
;
static
uint64_t
cur_ts
=
0
;
static
uint64_t
cur_ts
=
0
;
static
int
exiting
=
0
;
static
int
exiting
=
0
;
static
std
::
vector
<
struct
SimbricksNetIf
>
nsifs
;
static
std
::
vector
<
struct
SimbricksNetIf
>
nsifs
;
...
@@ -153,14 +153,14 @@ int main(int argc, char *argv[]) {
...
@@ -153,14 +153,14 @@ int main(int argc, char *argv[]) {
// Create sockets for Tofino model interfaces
// Create sockets for Tofino model interfaces
for
(
size_t
port
=
0
;
port
<
nsifs
.
size
();
port
++
)
{
for
(
size_t
port
=
0
;
port
<
nsifs
.
size
();
port
++
)
{
int
fd
=
socket
(
PF_PACKET
,
SOCK_RAW
,
htons
(
ETH
ER_TYPE
));
int
fd
=
socket
(
PF_PACKET
,
SOCK_RAW
,
htons
(
ETH
_P_ALL
));
if
(
fd
==
-
1
)
{
if
(
fd
==
-
1
)
{
fprintf
(
stderr
,
"Failed to create raw socket
\n
"
);
fprintf
(
stderr
,
"Failed to create raw socket
\n
"
);
abort
();
abort
();
}
}
char
ifname
[
16
];
char
ifname
[
16
];
sprintf
(
ifname
,
"veth%ld"
,
port
*
2
);
sprintf
(
ifname
,
"veth%ld"
,
port
*
2
+
1
);
struct
ifreq
ifopts
;
struct
ifreq
ifopts
;
memset
(
&
ifopts
,
0
,
sizeof
(
ifopts
));
memset
(
&
ifopts
,
0
,
sizeof
(
ifopts
));
strcpy
(
ifopts
.
ifr_name
,
ifname
);
strcpy
(
ifopts
.
ifr_name
,
ifname
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment