[ovs-dev] [flow-stats 10/14] flow: Make flow_compose() fake packets slightly more realistic.

Ben Pfaff blp at nicira.com
Mon Dec 19 22:54:31 UTC 2011


Thanks.  This completed the review, so I'll push this series to master
soon.

On Mon, Dec 19, 2011 at 02:50:34PM -0800, Ethan Jackson wrote:
> Works for me, thanks.
> 
> Ethan
> 
> On Mon, Dec 19, 2011 at 14:44, Ben Pfaff <blp at nicira.com> wrote:
> > OK, like this?
> >
> > diff --git a/lib/flow.c b/lib/flow.c
> > index a352f07..922412f 100644
> > --- a/lib/flow.c
> > +++ b/lib/flow.c
> > @@ -1036,7 +1036,8 @@ flow_compose(struct ofpbuf *b, const struct flow *flow)
> > ? ? ? ? ? ? }
> > ? ? ? ? }
> >
> > - ? ? ? ?ip->ip_tot_len = htons(b->data + b->size - b->l3);
> > + ? ? ? ?ip->ip_tot_len = htons((uint8_t *) b->data + b->size
> > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? - (uint8_t *) b->l3);
> > ? ? } else if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
> > ? ? ? ? /* XXX */
> > ? ? } else if (flow->dl_type == htons(ETH_TYPE_ARP)) {
> >
> > On Mon, Dec 19, 2011 at 02:34:30PM -0800, Ethan Jackson wrote:
> >> This doesn't compile on my system with the following warning.
> >>
> >> lib/flow.c:1039:40: error: pointer of type ?void *? used in arithmetic
> >> [-Werror=pointer-arith]
> >> lib/flow.c:1039:50: error: pointer of type ?void *? used in
> >> subtraction [-Werror=pointer-arith]
> >>
> >> Ethan
> >>
> >> On Mon, Dec 19, 2011 at 13:53, Ethan Jackson <ethan at nicira.com> wrote:
> >> > Looks good.
> >> >
> >> > Ethan
> >> >
> >> > On Thu, Dec 8, 2011 at 14:01, Ben Pfaff <blp at nicira.com> wrote:
> >> >> This makes flow_extract() happier with TCP packets that this function
> >> >> produces.
> >> >> ---
> >> >> ?lib/flow.c ? ?| ? ?3 +++
> >> >> ?lib/packets.h | ? ?1 +
> >> >> ?2 files changed, 4 insertions(+), 0 deletions(-)
> >> >>
> >> >> diff --git a/lib/flow.c b/lib/flow.c
> >> >> index a491aff..a352f07 100644
> >> >> --- a/lib/flow.c
> >> >> +++ b/lib/flow.c
> >> >> @@ -1020,6 +1020,7 @@ flow_compose(struct ofpbuf *b, const struct flow *flow)
> >> >> ? ? ? ? ? ? ? ? b->l4 = tcp = ofpbuf_put_zeros(b, sizeof *tcp);
> >> >> ? ? ? ? ? ? ? ? tcp->tcp_src = flow->tp_src;
> >> >> ? ? ? ? ? ? ? ? tcp->tcp_dst = flow->tp_dst;
> >> >> + ? ? ? ? ? ? ? ?tcp->tcp_ctl = TCP_CTL(0, 5);
> >> >> ? ? ? ? ? ? } else if (flow->nw_proto == IPPROTO_UDP) {
> >> >> ? ? ? ? ? ? ? ? struct udp_header *udp;
> >> >>
> >> >> @@ -1034,6 +1035,8 @@ flow_compose(struct ofpbuf *b, const struct flow *flow)
> >> >> ? ? ? ? ? ? ? ? icmp->icmp_code = ntohs(flow->tp_dst);
> >> >> ? ? ? ? ? ? }
> >> >> ? ? ? ? }
> >> >> +
> >> >> + ? ? ? ?ip->ip_tot_len = htons(b->data + b->size - b->l3);
> >> >> ? ? } else if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
> >> >> ? ? ? ? /* XXX */
> >> >> ? ? } else if (flow->dl_type == htons(ETH_TYPE_ARP)) {
> >> >> diff --git a/lib/packets.h b/lib/packets.h
> >> >> index 9e283a5..19b7346 100644
> >> >> --- a/lib/packets.h
> >> >> +++ b/lib/packets.h
> >> >> @@ -357,6 +357,7 @@ BUILD_ASSERT_DECL(UDP_HEADER_LEN == sizeof(struct udp_header));
> >> >> ?#define TCP_ACK 0x10
> >> >> ?#define TCP_URG 0x20
> >> >>
> >> >> +#define TCP_CTL(flags, offset) (htons((flags) | ((offset) << 12)))
> >> >> ?#define TCP_FLAGS(tcp_ctl) (ntohs(tcp_ctl) & 0x003f)
> >> >> ?#define TCP_OFFSET(tcp_ctl) (ntohs(tcp_ctl) >> 12)
> >> >>
> >> >> --
> >> >> 1.7.4.4
> >> >>
> >> >> _______________________________________________
> >> >> dev mailing list
> >> >> dev at openvswitch.org
> >> >> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list